I'm trying to get the position of a selected item like this:
//more code (adapter settings etc)
List.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
String selected_item= String.valueOf(adapterView.getItemAtPosition(i));
position=(Integer)List.getTag(); //without this line it doesn't crash
Toast.makeText(Main2Activity.this,"Please Log-In"+selected_item+"Thesi :"+String.valueOf(position),Toast.LENGTH_SHORT).show();
Intent toy = new Intent(Main2Activity.this,Main3Activity.class);
startActivity(toy);
}
});
It results on crashing my app.
Goal: i would like to have in a public variable (position) the position of a selected item
Logcat:
12-03 18:16:31.858 4421-4421/gr.aegean.icsd.myapplication W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
Let me mention that i'm new with android studio.