I am working on android example, when i click on checkbox then it gets the textviews value of first item(Position) in listview every time. so but i want to get value of selected (position) checkbox textview value. how to solve it please help .i am a fresher.Thanks in advances.
Some Code In BaseAdapter class
public View getView(int position, View convertView, ViewGroup parent)
{
ViewItem viewItem = null;
if(convertView == null)
{
viewItem = new ViewItem();
LayoutInflater layoutInfiater = (LayoutInflater)this.context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
//LayoutInflater layoutInfiater = LayoutInflater.from(context);
convertView = layoutInfiater.inflate(R.layout.list_adapter_view, null);
viewItem.txtTitle = (TextView)convertView.findViewById(R.id.inactivelistview);
// viewItem.txtDescription = (TextView)convertView.findViewById(R.id.adapter_text_description);
convertView.setTag(viewItem);
}
else
{
viewItem = (ViewItem) convertView.getTag();
}
viewItem.txtTitle.setText(valueList.get(position).username);
// viewItem.txtDescription.setText(valueList.get(position).cources_description);
return convertView;
}
Some Code in activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_get_in_active_list);
listCollege = (ListView)findViewById(R.id.listCollege);
proCollageList = (ProgressBar)findViewById(R.id.proCollageList);
checkbox = (CheckBox)findViewById(R.id.checkbox_me);
button =(Button)findViewById(R.id.button1);
new GetHttpResponse(this).execute();
}
public void onCheckboxClicked(View view) {
boolean checked = ((CheckBox) view).isChecked();
switch(view.getId()) {
case R.id.checkbox_me:
if (checked) {
username = (TextView)findViewById(R.id.inactivelistview);
Username =username.getText().toString();
System.out.println("print username_=== "+Username);
AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
alertbox.setMessage("Do you want activate "+Username+"?");
alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), Username+" acivated", Toast.LENGTH_SHORT).show();
}
});
alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), "'No' button clicked", Toast.LENGTH_SHORT).show();
}
});
alertbox.show();
} else
break;
}
I am getting textviews value of first item(Position) in listview every time. Please help me how to solve.help me update my code Thank you so much.......
Aucun commentaire:
Enregistrer un commentaire