当从微调器中选择一个项目并单击go按钮时,我必须打开一个新活动。但是当点击go按钮时,应用程序停止工作。
public void onClick(View arg0) {
// TODO Auto-generated method stub
String check = branchText.getText().toString();
String check1 = semText.getText().toString();
if(check.equals("Information Technology")&&check1.equals("1st"))
{
Intent it=new Intent(MainActivity.this, IT1stSem.class);
startActivity(it);
}
}
public class IT1stSem extends ListActivity {
String[] data = {"Mathematics-I", "Physics-I", "Chemistry", "Engg. Mechanics", "Electrical Science"};
ListView l;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.it1stsem);
l=getListView();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.it1stsem, data);
l.setAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
TextView temp = (TextView) v;
Toast.makeText(this, ""+temp.getText()+ " "+position, Toast.LENGTH_SHORT).show();
}
}
答案 0 :(得分:1)
从Logcat可以清楚地看出,您尚未在清单中声明您的活动(您要去的地方)。
在Manifest中,声明你的IT1stSem类:
<activity android:name="yourpackageName.IT1stSem" >
</activity>