i followed numerous tuitorials like http://www.javacodegeeks.com/2013/09/android-listview-with-adapter-example.html Also followed the questions asked here How to make custom
By doing this way you don't have to write all the switch case for activity.
public class MainActivity extends Activity {
ListView list;
String[] web = {
"Notifications",
"School",
"What's Hot",
"Tell a friend",
"Hit us up",
"Settings",
"About & Help"
};
String[] s1 = {
"Notifications",
"School",
"Whats_hot",
"Tellafriend",
"Hitusup",
"Settings",
"AboutHelp"
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CustomList adapter = new
CustomList(MainActivity.this, web, imageId);
list=(ListView)findViewById(R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view,
int position, long id) {
String a=s1[position];
Class a1= null;
try {
a1 = Class.forName("."+a);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
startActivity(new Intent(MainActivity.this,a1));
}
@SuppressWarnings("unused")
public void onClick(View v){
};
});
}
}
Don't forget to put point '.' immediately after your package name.