I have two activities (Main & Sub) both contain list view to display images. I want to reuse the sub activity for displaying the images according to the cell click in the main activity (some thing like Restaurant Menu). So I have declared an array of integer arrays (Images in drawable folder) that I want to pass to sub activity and the subadapter
I tried below code, but I ended with the Int and Integer conflict.
main activity
public class AppsMenu extends AppCompatActivity {
ListView appsmainlist;
Integer[] images={R.drawable.res,R.drawable.clo,R.drawable.beu,R.drawable.col,R.drawable.tor,R.drawable.hot};
Integer[][] subarray = {{R.drawable.res1,R.drawable.res2,R.drawable.res3,R.drawable.res4},{R.drawable.clo1,R.drawable.clo2,R.drawable.clo3,R.drawable.clo4}};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apps_menu);
appsmainlist = (ListView) findViewById(R.id.appsmainlist);
appsmenuadapter appsmenuadapter = new appsmenuadapter(this,images);
appsmainlist.setAdapter(appsmenuadapter);
appsmainlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(AppsMenu.this,appsview.class);
intent.putExtra("subarray",subarray[i]);
startActivity(intent);
}
});
}
}
sub Activity
ListView appsviewlist;
Integer [] appsviewarray;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appsview);
appsviewlist = (ListView) findViewById(R.id.appsviewlist);
// Error goes here
appsviewarray = getIntent().getIntArrayExtra("subarray");
appsviewadapter appsviewadapter = new appsviewadapter(this,appsviewarray);
}
Adapter :
public class subadapter extends ArrayAdapter<Integer> {
...
}
Any help will be much appreciated.