private void firstyearsublist() {
//string array for intents
String[] intents = {"Calculus","eee","eee","cpu","physics","chemistry","es","be","vcla"};
//CREATE STRINGLIST
String[] subs = {"Calculus","EME","EEE","CPU","Physics","Chemistry","ES","BE","VCLA"};
//BUILD ADAPTER
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, subs);
//Configure list view
ListView sublist = (ListView) findViewById(R.id.firstyearsub);
sublist.setAdapter(adapter1);
sublist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
for(int i = 0;i<9;i++)
{if (position == i) {
Intent intents[i] =
new Intent(Sem1.this, intents[i]. class);
startActivity(intents[i]);
}
}
}
}
);
}}
我正在制作一个应用程序,用于访问我所在学院所有学期的工程综合笔记。我收到太多错误。难道我做错了什么?请查看代码。
答案 0 :(得分:0)
这实际上是你应该怎么做的
//replace with your activity classess
Class intents[] = {ClassA.class,ClassB.class,ClassC.class,ClassS.class};
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
startActivity(new Intent(BaseActivity.this,intents[position]));
}
});