java.lang.RuntimeException: Unable to start activity ComponentInfo {com.example.uiceshi / com.example.uiceshi.MainActivity}: java.lang.NullPointerException
Configuration
android: icon = "@ drawable / ic_launcher"
android: label = "@ string / app_name"
android: theme = "@ style / AppTheme">
android: label = "@ string / ArrayAdapter">
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
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:
. . . . I said, looking half right ah. . . .
No comments:
Post a Comment