So here what im trying to do. Im trying to set a variable that i can bring up later in another Activity but in the same packege.
SO I created the Variable and even tested in in the toast to make sure it works. Now I need to call on that variables information in the following code
This is not working for me. How do i call upon that information?
Code:
public class MainActivity extends Activity {
private int Item_Selected = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
/** Called when the a pic is selected. */
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Item_Selected = position;
Toast.makeText(MainActivity.this, "" + Item_Selected, Toast.LENGTH_SHORT).show();
Intent myIntent = new Intent(MainActivity.this, TabsActivity.class);
MainActivity.this.startActivity(myIntent);
}
});
}
}
SO I created the Variable and even tested in in the toast to make sure it works. Now I need to call on that variables information in the following code
Code:
private int Item_Selected;
public class SyllabusTabActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Item_Selected == 0) {
String[] Belt_Array = getResources().getStringArray(R.array.TanBelt_Array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_items, Belt_Array));
}else {
String[] Belt_Array = getResources().getStringArray(R.array.GrayBelt_Array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_items, Belt_Array));
}}
This is not working for me. How do i call upon that information?