我有一个列表视图,它通过键“hubahuba”从不同活动中的编辑文本接收用户输入。当我单击包含此 .class 的水龙头时,我收到基于 logcat 的 NullPointerException 错误,我知道这与我的“String trackinput”行有关请任何帮助人员???
public static ArrayList<String> list = new ArrayList<String>();
public static ArrayAdapter<String> adapter;
LisstView lv;
String trackinput;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_argue_list);
//listViewCode
ListView lv = (ListView)findViewById(android.R.id.list);
//Intent to receive from other activity
Intent i = getIntent();
String trackinput = i.getExtras().getString("hubahuba");
//basic adapter
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
lv.setAdapter(adapter);
list.add(0, trackinput);
adapter.notifyDataSetChanged();
setListAdapter(adapter);
}
这是从活动 1 到活动 2 中的列表视图:
public void onClick(View v) {
Intent i = new Intent(this, ArgueListActivity.class);
i.putExtra("hubahuba",whatedit.getText().toString());
whatedit.setText("");
}