Urvesh Patel
Urvesh Patel

Reputation: 11

how to make multiple buttons visible in listview on one buttons click in android?

i had made one layout, in this layout one button is in header and now i want that when user clicks on the header button in the listview, multiple button become visible. How can i do this? Pls reply

public View getView( final int position, View convertView, ViewGroup parent) {
        String mText = mlist.get(position);
        LayoutInflater vi = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.custom_will, null);
        TextView txt = (TextView) convertView
                .findViewById(R.id.txtcustomwill);
        final Button deletbtn = (Button)convertView.findViewById(R.id.btndelete);
        Button bt = (Button)convertView.findViewById(R.id.btnchange);
        Log.v("palak", "bar         "  + position  );
            txt.setText(mText);
            lv.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View v,
                        int position, long Id) {
                    if(position == 0){
                    dba = DBAdapter.getDBAdapterInstance(getApplicationContext());
                    try {
                        dba.createDataBase();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    if (save) {
                    sqldb = dba.openDataBase();
                    ContentValues cv = new ContentValues();
                    cv.put("todayDate", "UnNamed Entry");
                    cv.put("fname", "UnNamed Entry");
                    cv.put("sname", "UnNamed Entry");
                    cv.put("add1", "UnNamed Entry");
                    cv.put("add2", "UnNamed Entry");
                    cv.put("add3", "UnNamed Entry");
                    cv.put("pcode", "UnNamed Entry");
                    sqldb.insert("urdet", null,cv);
                    cv.clear();
                    Toast.makeText(getApplicationContext(), "inserted", Toast.LENGTH_SHORT).show();
                    }
                    dba.close();
                    Intent i = new Intent(Yourwill.this, Section.class);
                    startActivity(i);
                    finish();
                }
                else
                {
                    Willdto.setposition(Integer.parseInt(aId.get(position)));
                    Intent i = new Intent(Yourwill.this, Section.class);
                    startActivity(i);
                    finish();
                }
                }

            });
            deletbtn.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    SQLiteDatabase sqldb = dba.openDataBase();
                    String[] arr = { "" + aId.get(position) };
                    sqldb.delete("urdet", "Id = ?", arr);
                    Toast.makeText(getApplicationContext(), "Delete", Toast.LENGTH_SHORT).show();
                    Log.v("log_tag", "pos   " + aId.get(position));
                    dba.close();
                    Intent i = new Intent(Yourwill.this,Yourwill.class);
                    startActivity(i);
                    finish();
                }
            });
            bt.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    deletbtn.setVisibility(View.VISIBLE);
                }
            });

        return convertView;
    }

}

Upvotes: 0

Views: 560

Answers (1)

Rahul Choudhary
Rahul Choudhary

Reputation: 3809

The way to do this would be to

  1. Have those buttons created with attribute android:visibility="gone"
  2. Inside the onClick handler for top button change the visibility using setVisibility(View.VISIBLE)

Upvotes: 2

Related Questions