SQLController dbcon;
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String children = (String) getChild(groupPosition, childPosition);
TextView text;
if (convertView == null) {
convertView = inflater.inflate(R.layout.listrow_details, null);
}
text = (TextView) convertView.findViewById(R.id.textView1);
text.setText(children);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(activity, children,Toast.LENGTH_SHORT).show();
}
});
convertView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
AlertDialog.Builder Delete=new AlertDialog.Builder(activity);
Delete.setTitle("Show Linups Or Delete");
Delete.setMessage("Press Delete For Remove "+children+" or Press Show Lineups to get Lineups.");
Delete.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dbcon=new SQLController(activity);
dbcon.open();
Cursor c=dbcon.returnData();
if(c.moveToFirst())
{
do{
if(children.equals(c.getString(0))){
dbcon.deleteData(children);
notifyDataSetChanged();
Toast.makeText(activity,"Successfully Deleted",Toast.LENGTH_LONG).show();
break;
}
}while(c.moveToNext());
}
dbcon.close();
}
}).show();
return false;
}
});
return convertView;
}
This is my Group class with List in it,
public class Group {
public String string;
public final List<String> children = new ArrayList<String>();
public Group(String string) {
this.string = string;
}
}
This is my Expandable list adapter's getChildView Method, I am using Sqlite
database and I store data to database and need to delete some items also so i use onLongClickListener
for Deleting items, when I long click on the item I want to delete a popup appears having delete button, when I click on that button the item from database deleted but the item still appears on that activity until I reopen the application, what I want is when I click on delete button it should be disappear from that list also immediately,
Thanks in Advance,