Thursday, February 27, 2014

How Dialog Builder under the click event can jump to a new Activity? Seeking education


I enclose my code:
Builder builder = new AlertDialog.Builder (this.Context); / / create dialog
builder.setTitle (R.string.tip); / / set the dialog title
builder.setMessage (R.string.not_setting_current_region); / / Settings dialog information
/ * Set dialog confirmation button * /
builder.setPositiveButton (R.string.confirm, new DialogInterface.OnClickListener ()
{

@ Override
public void onClick (DialogInterface dialog, int which)
{

dialog.dismiss ();
Intent intent = new Intent (Activity_SSGJ.this, Activity_select_City.class);
startActivity (intent);

Log.i (YangJ, "you click on the OK!");

}
});

I do not understand is why this jump was unsuccessful, click OK to stop? Great God seeking education<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
So write should be fine, ah, what's your problem?
Reply:
Intent intent = new Intent (Activity_SSGJ.this, Activity_select_City.class);
Activity_SSGJ.this.startActivity (intent);
Try this
Reply:
Error Log paste ~
Reply:

There is a null pointer exception.
Reply:
reference to the second floor yinke22222 reply:
Intent intent = new Intent (Activity_SSGJ.this, Activity_select_City.class);
Activity_SSGJ.this.startActivity (intent);
Try this
like this is not OK I do not know how to engage, you can jump button is placed inside this popup will not work
Reply:
 
Builder builder = new AlertDialog.Builder (this); / / create dialog
builder.setTitle ("title"); / / Set the dialog title
builder.setMessage ("test"); / / Settings dialog information
/ * Set dialog confirmation button * /
builder.setPositiveButton ("OK", new DialogInterface.OnClickListener () {

public void onClick (DialogInterface dialog, int which) {

dialog.dismiss ();
Intent intent = new Intent (MainActivity.this, TwoActivity.class);
MainActivity.this.startActivity (intent);

}
.}) Show ();

I tried the normal jump ah. . .
Reply:
1, these two plus AlertDialog dialog = builder.create ();
dialog.show ();
Reply:
There is a list of files in your activity registered yet
Reply:
 public class MainActivity extends Activity {
private Button btn;
@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
btn = (Button) findViewById (R.id.button1);
btn.setOnClickListener (new OnClickListener ()
{

@ Override
public void onClick (View arg0)
{
AlertDialog.Builder builder = new Builder (MainActivity.this);
builder.setMessage ("Confirm Exit right?");

builder.setTitle ("Tip");

builder.setPositiveButton ("Confirm", new DialogInterface.OnClickListener () {

@ Override
public void onClick (DialogInterface dialog, int which) {
dialog.dismiss ();

Intent intent = new Intent (MainActivity.this, MainActivity2.class);
startActivity (intent);
}
});

builder.setNegativeButton ("Cancel", new DialogInterface.OnClickListener () {

@ Override
public void onClick (DialogInterface dialog, int which) {
dialog.dismiss ();
}
});

builder.create () show ();.
}
});

}

I wrote one, not being given ah
You refer to
Reply:
Builder builder = new AlertDialog.Builder (this.Context); / / create dialog
- "
Builder builder = new AlertDialog.Builder (this); / / create dialog
I do not know what your this.Context is combined with a test of children's shoes, 6th Floor, reckoned that the problem is
Reply:
reference to the 6th floor yinke22222 reply:
Java code 1234567891011121314Builder builder = new AlertDialog.Builder (this); / / create dialog builder.setTitle ("title? "); / / set dialog title builder.setMessage (" test "); / / Setup dialog box message / * Set the dialogue ......
my grass, and I built a project can be jump. Spicy next door
Reply:
reference to the 8th floor kaka520169 reply:
There is a list of files in your activity registered yet
registered estimated I have a problem code structure
Reply:
Get.
Reply:
reference to the 13th floor YangJ0720 reply:
get.

This is how you solve the landlord, I also encountered the same problem

No comments:

Post a Comment