Posts by Kelly Goedert

18 May 2011, 12:26
Generic-user-small

Kelly Goedert (2 posts)

(from Hello, Android (3rd edition) > about box)

First of all, great book!
I’m having a problem trying to show the about box of section 3.5. When I click the about button, the main screen seems to reload. Here is the code:


public class About extends Activity {    
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}


public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);

          // Set up click listeners for all the buttons
          View continueButton = findViewById(R.id.continue_button);
          continueButton.setOnClickListener(this);
          View newButton = findViewById(R.id.new_button);
          newButton.setOnClickListener(this);
          View aboutButton = findViewById(R.id.about_button);
          aboutButton.setOnClickListener(this);
          View exitButton = findViewById(R.id.exit_button);
          exitButton.setOnClickListener(this);
       }

       // ...
       public void onClick(final View v) {
          switch (v.getId()) {
          case R.id.about_button:
             Intent i = new Intent(this, About.class);
             startActivity(i);
             break;
          // More buttons go here (if any) ...
          case R.id.new_button:
             //openNewGameDialog();
             break;
          case R.id.exit_button:
             finish();
             break;
          }
       }
}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/background" android:orientation="horizontal" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:padding="30dip">
    <LinearLayout android:background="@color/background" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center">
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/main_title" android:layout_gravity="center" android:layout_marginBottom="25dip" 
            android:textSize="24.5sp" />
        <Button android:id="@+id/continue_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/continue_label" />
        <Button android:id="@+id/new_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/new_game_label" />
        <Button android:id="@+id/about_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/about_label" />
        <Button android:id="@+id/exit_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/exit_label" />
    </LinearLayout>
</LinearLayout>


<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dip">
    <TextView android:id="@+id/about_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/about_text" />
</ScrollView>

Thanks for any help

14 Apr 2012, 12:05
Generic-user-small

Kelly Goedert (2 posts)

(from I'd Like a Book That Covers… > private cloud)

On how can I start to build my own private cloud

2 posts