I want to go from listview adapter itemview click listener to fragment with extra details that i want to use in that fragment where i go..I use this list view adapter class.I want to go from listview adapter itemview click listener to fragment with extra details that i want to use in that fragment where i go..I use this list view adapter class.
public class ListViewAdapter extends BaseAdapter {
// Declare Variables
Context context;
LayoutInflater inflater;
ArrayList<HashMap<String, String>> data;
HashMap<String, String> resultp = new HashMap<String, String>();
public ListViewAdapter(Context context, ArrayList<HashMap<String, String>> arraylist) {
this.context = context;
data = arraylist;
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
public View getView(final int position, View convertView, ViewGroup parent) {
// Declare Variables
TextView ip;
TextView port;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.listview_item, parent, false);
// Get the position
resultp = data.get(position);
// Locate the TextViews in listview_item.xml
ip = (TextView) itemView.findViewById(R.id.ip);
port = (TextView) itemView.findViewById(R.id.port);
// Locate the ImageView in listview_item.xml
// Capture position and set results to the TextViews
ip.setText(resultp.get(AddFragment.ip));
port.setText(resultp.get(AddFragment.port));
// Capture position and set results to the ImageView
// Passes flag images URL into ImageLoader.class
// Capture ListView item click
itemView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// Get the position
resultp = data.get(position);
Intent intent = new Intent(context, MainActivity.class);
// Pass all data rank
intent.putExtra("ip", resultp.get(AddFragment.ip));
// Pass all data country
intent.putExtra("port", resultp.get(AddFragment.port));
intent.putExtra("uname", resultp.get(AddFragment.uname));
intent.putExtra("password", resultp.get(AddFragment.password));
Log.e("uname: ", "> " + resultp.get(AddFragment.uname));
Log.e("password: ", "> " + resultp.get(AddFragment.password));
Log.e("ip: ", "> " + resultp.get(AddFragment.ip));
Log.e("port: ", "> " + resultp.get(AddFragment.port));
// Pass all data population
// Pass all data flag
// Start SingleItemView Class
context.startActivity(intent);
}
});
return itemView;
}
so How i can go to fragment instead of activity. I want to go in fragment with this put extra detailss. so, How i can go?