This will probably have an obvious answer to many but I can't seem to figure it out. I am trying to make an api call within an android application, but keep running into "..... cannot be resolved" I have three Java classes, FoodSearchActivity, GetItemsActivity and GetData!
FoodSearchActivity extends Activity;
This class declares the following
public ListView list;
public Button btnSearch;
public EditText txtFoodSearch;
but in the GetItemsActivity
class, txtFoodSearch
cannot be resolved unless I extend FoodSearchActivity
. Which in turn means I can't implement AsyncTask
. When GetItemsActivity
does implement AsyncTask
I get the error:
" The type AsyncTask<String,String,String> cannot be a superinterface of GetItemsActivity; a superinterface must be an interface"
GetItemsActivity extends FoodSearchActivity;
To try solve this I created a new class GetData
which extends AsyncTask<String, String, String>
GetData extends AsyncTask<String, String, String>
I have no errors when i do this but when I do
txtFoodSearch.getText().toString();
I am back at the txtFoodSearch
cannot be resolved. txtFoodSearch
is an EditText
field which takes user input. How can i change this so txtFoodSearch
is visible in the other classes??
It's already declared as public. Any tips or advice would be great. Can post source code if needed!