0

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;
    }

}
0

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.