Wednesday, January 22, 2014

How do the activity being given a jump. . .


            
java.lang.RuntimeException: Unable to start activity ComponentInfo {com.example.uiceshi / com.example.uiceshi.MainActivity}: java.lang.NullPointerException

Configuration

android: allowBackup = "true"
android: icon = "@ drawable / ic_launcher"
android: label = "@ string / app_name"
android: theme = "@ style / AppTheme">
android: name = ". MainActivity"
android: label = "@ string / ArrayAdapter">







android: name = ". mListView"
android: label = "mListView"> /



The first activity
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
mButton.setOnClickListener (this);

}

@ Override
public void onClick (View v) {
/ / TODO Auto-generated method stub
Intent intent = new Intent ();
intent.setClass (MainActivity.this, mListView.class);
startActivity (intent);

The second
@ Override
protected void onCreate (Bundle savedInstanceState) {
/ / TODO Auto-generated method stub
super.onCreate (savedInstanceState);
listView = new ListView (this);
listView.setAdapter (new ArrayAdapter (this,
android.R.layout.simple_expandable_list_item_1, getData ()));
setContentView (listView);
}
Reply:
mButton.setOnClickListener (this);
The landlord is quoted phrase null pointer exception, right?
Here mButton you have not instantiated, the above phrase preceded by a
Button mButton = (Button) findViewById (R.id.button);
mButton.setOnClickListener (this);
Reply:
cited a floor ncepu307 reply:
mButton.setOnClickListener (this);
The landlord is quoted phrase null pointer exception, right?
Here mButton you have not instantiated, the above phrase preceded by a
Button mButton = (Button) findViewById (R.id.button);
mButton.setOnClickListener (this);


. . . . I said, looking half right ah. . . .

No comments:

Post a Comment