About adt android development issues:
In the layout I have two interfaces, one is the main interface activity_main.xml and another new interface form1.xml.
I add a new button (id = @ + id / bt_one) in activity_main, want to click bt_one pop-up screen form1.
My practice is in the MainActivity.java src code is as follows:
package com.example.my_first;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
Button bt_one = (Button) this.findViewById (R.id.bt_one);
bt_one.setOnClickListener (new View.OnClickListener () {
@ Override
public void onClick (View arg0) {
/ / TODO Auto-generated method stub
Intent intent = new Intent (MainActivity.this, activeform1.class);
startActivity (intent);
}
});
}
@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.main, menu);.
return true;
}
Then I added the following in src a class: activeform1.java, code is as follows:
package com.example.my_first;
import android.app.Activity;
import android.os.Bundle;
public class activeform1 extends Activity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
/ / TODO Auto-generated method stub
super.onCreate (savedInstanceState);
setContentView (R.layout.form1);
}
}
Compile, run the main interface activity_main.xml, when you click the button on the main interface, not bombs interface form1.xml, error: Unfortunately, my_first has stopped.
Will the code wrong?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
activeform1 To Manifest in registration, otherwise it will not find this Activity Report an error.
Reply:
How to register, talk
Reply:
Manifest the following sentence into the application tag
Reply:
Upstairs positive solution! Sign up!
Reply:
Four components must be registered in the Manifest.xml
Reply:

Reply:






Reply:

No comments:
Post a Comment