本文介绍了无法启动活动ComponentInfo ..... java.lang.IllegalStateException:已附加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了这个错误,如您所见,我正在添加从第一个活动中获取的数据并将其存储到第二个活动中的数组中.然后我使用数组填充列表视图.所以问题出在我单击第一个视图上的保存按钮时公共类Main2Activity扩展了AppCompatActivity {
I m getting that error ,as you can see i m adding the data that i grabbed from the first activity and storing it into the my array in the second activity .Then i use the array to populate the list view .So the problem is whenever i click to the save button on the first viewpublic class Main2Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
super.onCreate(savedInstanceState);
// setContentView(Your_Layout);
//Bundle extras = null;
//if(getIntent().getExtras() != null){
// extras = getIntent().getExtras();
//}
Intent intent = getIntent();
// ListView lv = (ListView) findViewById(R.id.View);
String data = intent.getStringExtra("data");
String first = intent.getStringExtra("stringOne");
String second = intent.getStringExtra("stringTwo");
String Third = intent.getStringExtra("stringThree");
String Fourth = intent.getStringExtra("stringFour");
String Fifth = intent.getStringExtra("stringFive");
String Sixth = intent.getStringExtra("stringSix");
// Find the ListView resource.
ListView lv = (ListView) findViewById( R.id.View );
// Create and populate a List of planet names.
String[] dataUser = new String[] { first,second,Third,Fourth,Fifth,Sixth};
ArrayList<String> dataList = new ArrayList<String>();
dataList.addAll(Arrays.asList(dataUser));
// Create ArrayAdapter using the planet list.
ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dataList);
// Set the ArrayAdapter as the ListView's adapter.
lv.setAdapter(listAdapter);
}
}
推荐答案
您的代码中有2个super.onCreate(savedInstanceState);
,请删除其中之一.
You have 2 super.onCreate(savedInstanceState);
in your code, remove one of them.
这篇关于无法启动活动ComponentInfo ..... java.lang.IllegalStateException:已附加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!