I have a ListView below with an ArrayAdapter to make a simple List view with corresponding Html elements added to assets folder.
Is there a way to Change Class variable from inner Method java android xml android-studio I have a ListView below with an ArrayAdapter to make a simple List view with corresponding Html elements added to assets folder. import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import android.content.Intent; public class MainActivity extends ListActivity { String indx; String[] values = { "index", "Prooo", "My Android Examples","My Android Tutorials","My Android Pages", "My Android Favorites"}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // parameters are (Context, layout for the row, and the array of data) setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values)); } @Override public void onListItemClick(ListView l, View v, int position, long id) { indx = (String) getListAdapter().getItem(position); Toast.makeText(this,indx,Toast.LENGTH_SHORT).show(); Intent i=new Intent(MainActivity.this,WebViewActivity.class); startActivity(i); } }
Everything else works fine but the aim is to change the String indx value with the item Position returned by onListItemClick as each Html document's name is the same as that of each String values item. I tired to access indx from a class WebViewActivity to display the Html but the String indx value is still Null. I would've specify something like Public indx if it was Python please is there any way to change Indx like that in Java and I can't use return because void cannot return
indx
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)