我有GridView
:
GridView gridView = (GridView) findViewById(R.id.grid_view);
// Instance of ImageAdapter Class
final String [] imageNames = {"knee_kg","knee_ks","knee_kp","knee_kg_90",
"pipe_knee", "cover", "funnel", "crater"};
Integer[] mThumbIds = new Integer[imageNames.length];
for (int i = 0; i<imageNames.length; i++){
Integer resID = getResources().getIdentifier(imageNames[i], "drawable",
getPackageName());
mThumbIds[i] = resID;
}
和OnItemCliclListener
:
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
Class clazz = null;
String className = imageNameToUpper(imageNames[position]);
try {
clazz = Class.forName("com.example.pipecalculator.activities." + className);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Intent intentClass = new Intent(getApplicationContext(), clazz);
startActivity(intentClass);
}
});
我只想在两个项目单击时创建上下文菜单:"knee_ks"
, "knee_kp"
. 另一方面是:
Intent intentClass = new Intent(getApplicationContext(), clazz);
startActivity(intentClass);
这是可能的?