In my application I have a listview. I have to pass the position of the row clicked to the next screen. But it is showing as null … please help me …
Here is my listview code:
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
intent.putExtra("Pos", position);
}
});
My another screen where I am getting this pos:
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0)
{
Intent intent=getIntent();
String pos=intent.getStringExtra("Pos");
System.out.println("Pos="+pos);
int position=Integer.parseInt(pos);
}
});
The problem is here,
You are passing a int value and you are checking for String value which obviously is not correct.
Change it to,
By this, it means that the key for your put Extra Data Types are independent from the type of Data itself. So ensure that you pass it as int and get it as int.