Anthony,
There is only one content view per activity. If you change it, then
change back, then you need to obtain new UI element references by
calling findViewById all over again.
Second, if "android.intent.action.CODE" is your own action string, don't
start it with "android".
Third, you can handle the back button if needed by overriding onKeyDown
and checking for "keyCode == KeyEvent.KEYCODE_BACK".
Hope this helps.
-- Kostya
08.01.2011 20:38, Anthony Barnes ?????:
Not sure if I am doing this right, but here is what I am trying to do.
I got my CodeActivity(Code Below) that assigns a bunch of buttons.
On button 4, I pull up another contentView to display some buttons
under that particular button.
Then on the button 4(or the back button) I want to return to the
previous page of the CodeActivity.
If i hit the back button, the app exits so I tried putting a back
button on the form and setting it back to the original contentview but
then the buttons didn't work for the original codeactivty page.
I need another pair of eyes to help me work through this issue.
package info.tAIR.tAIRApp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class CodeActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.codetab);
final Button button01 = (Button)
findViewById(R.id.Button01);
button01.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Uri uri = Uri.parse("http://code.google.com/p/the-ai-repository");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
final Button button02 = (Button)
findViewById(R.id.Button02);
button02.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Uri uri =
Uri.parse("http://code.google.com/p/the-ai-repository/downloads/list");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
final Button button03 = (Button)
findViewById(R.id.Button03);
button03.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Uri uri =
Uri.parse("http://code.google.com/p/the-ai-repository/source/browse/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
final Button button04 = (Button)
findViewById(R.id.Button04);
button04.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on contributors click
// onPause();
setContentView(R.layout.contributors);
final Button button01 = (Button)
findViewById(R.id.Button01);
button01.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Uri uri = Uri.parse("http://www.tAIIC.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
final Button button02 = (Button)
findViewById(R.id.Button02);
button02.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Uri uri = Uri.parse("http://sites.jsoft.com/rm/home");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
final Button button03 = (Button)
findViewById(R.id.Button03);
button03.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Uri uri = Uri.parse("http://www.suavestudio.com/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});
final Button button04 = (Button)
findViewById(R.id.Button04);
button04.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Intent newIntent=new Intent("android.intent.action.CODE");
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(newIntent);
}
});
}
});
final Button button05 = (Button)
findViewById(R.id.Button05);
button05.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Perform action on click
Toast.makeText(CodeActivity.this, "tAIR Companion App v2.0\n\n
Copyright @ 2010-2011\n\n http://www.tAIR.info",
Toast.LENGTH_LONG).show();
// }
// });
}
});
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en