我有一個自定義listview
其中包含button
和textview
。 textview
知名度消失了。當button
文本是「電子郵件」,並且如果我點擊button
,textview
應該顯示在button
的下面。但最後的textview
總是變得可見。下面textview在列表視圖中不可見時在某一行上單擊按鈕
@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
wantedUsers du = wusers.get(i);
final String mcontact = du.mcontact;
if(view==null) {
viewholder = new viewholder();
view = LayoutInflater.from(ws).inflate(R.layout.wantedmoviecustom, null);
viewholder.mcontwcustom = (Button)view.findViewById(R.id.mcontwcustom);
viewholder.mdisplayemail = (TextView) view.findViewById(R.id.mdisplayemail);
view.setTag(viewholder);
} else {
viewholder = (viewholder) view.getTag();
}
viewholder.mdisplayemail.setVisibility(View.GONE);
if(mcontact.contains("@")) {
viewholder.mcontwcustom.setText("Show Email");
viewholder.mdisplayemail.setText(mcontact);
} else {
viewholder.mcontwcustom.setText("Call");
}
viewholder.mcontwcustom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mcontact.contains("@")) {
int p=(Integer)view.getTag();
viewholder.mdisplayemail.setVisibility(View.VISIBLE);
// viewholder.mdisplayemail.setText(mcontact);
}
else
{
Uri call = Uri.parse("tel:" + mcontact);
Intent surf = new Intent(Intent.ACTION_DIAL, call);
ws.startActivity(surf);
}
}
});
viewholder.mcontwcustom.setTag(i);
return view;
}
是我getview
從定製adapter
。那麼當button
點擊特定的行時,如何才能製作textview
visbile
。
你需要改變'viewholder.mdisplayemail.setVisibility();'to viewholder.mdisplayemail.setVisibility(View.VISIBLE);' – UltimateDevil
讓我看看你的佈局? –
@ user2269164檢查我的答案可能會解決您的問題 – UltimateDevil