I have a customAdapter whose .xml for the views in the grid is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="120dp"
android:orientation="vertical">
<ImageView
android:id="@+id/imagepart"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:gravity="top"/>
<TextView
android:id="@+id/textpart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor = "#000000"
android:gravity="top"/>
</LinearLayout>
In this custom adapter i have a method to return an string from a private array.
public class DishesImageAdapter extends BaseAdapter {
...
public String getName(int position) {
if(position > 0 && position >= mThumbsNames.length)
{
return mThumbsNames[position];
}
return null;
}
...
}
I would like to call this former method inside of onItemClick, i have tried several ways through "parent" object but i cant...
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Intent DishDetailsIntent = new Intent(v.getContext(), DishesDetails.class);
DishDetailsIntent.putExtra("SectorNum", getIntent().getStringExtra("SectorNum"));
String DishName = //
DishDetailsIntent.putExtra("DishName", DishName);
startActivity(DishDetailsIntent);
}
Any help?
Thanks in advance.
Finally i got the answer:
TextView tv= (TextView) v.findViewById(R.id.textpart);
String DishName = tv.getText().toString();
DishDetailsIntent.putExtra("DishName", DishName);