For example I have a method like this. If you see the String ‘tablenumber’ I want to be able to use it in a later function such as a onclick button so I can send the contents of it to a different activity. But if I use this variable outside the method it’s not recognised. How do I go about this.
{
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String tablenumber = (String) arg0.getSelectedItem();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
you can make the scope of your variable global for your whole activity like this