<Button
android:text="More Info"
android:id="@+id/btninfo"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:onClick="myClickHandler"
>
// Listens to user selecting on an item/row
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parentView, View view, int position, long id) {
Hashtable<String,String> listOfData = new Hashtable<String,String>();
/* Retrieve the data of the particular item selected based on the position of the item
* and pass it to the next activity
*/
listOfData = listData.get(position);
Intent detailedView = new Intent();
detailedView.setClassName("com.", "com.");
detailedView.putExtra("listOfData", listOfData);
startActivity(detailedView);
}
});
};
This works fine as I'm able to click on the row which intents into another activity.
public void myClickHandler(View view){
String info = listData.get(position).get("coverImage");
Intent infoIntent = new Intent(android.content.Intent.ACTION_VIEW);
infoIntent.setData(Uri.parse("http://......=" + info + "......."));
startActivity(infoIntent);
}
The problem starts here. When I click on the button in the first list view row, it intents to the correct web view for the particular item in the position. But when I click on the rest of the buttons in the list view rows it keeps returning the same webview intended only for the first position in the list view. Hmm, i want the buttons on the different rows to intent into different urls(intent to webview) according to their position in the list view. My guess the problem lies in the application not being able to detect the position?
I'm still a newbie with android and have been trying for days~ So any help given is much appreciated! Thanks in advance! Sorry if the way my question is phrased seemed confusing~
// What I've declared in a Adapter~
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}