2011-09-22 59 views
0

我做了一個佈局,在這個佈局中,一個按鈕在標題中,現在我希望當用戶點擊列表視圖中的標題按鈕時,多個按鈕變得可見。我怎樣才能做到這一點?請回復如何讓多個按鈕在一個按鈕上的ListView中可見點擊在Android中?

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

您需要添加一些代碼 – blessenm

回答

2

做的方式,這將是

  1. 有屬性的Android創建這些按鈕:知名度=「水漲船高」
  2. 裏面的onclick處理頂部的按鈕使用改變的可視性setVisibility(View.VISIBLE)
+0

這也會有效。 –

相關問題