2012-03-28 8 views
0

[TextView1] [TextView2] [ボタン]Android-は、私は同じlistrow


は、リストの行が含まれている2のTextViewのボタンをクリックでリストビューの列でのTextViewのvisibiltyを設定したいです1ボタン。

[TextView2]可視性は、最初はView.GONEに設定されています。

  1. 要件はvisibiltyを設定する必要がありView.VISIBLE
  2. および[ボタン]の次のクリックに対して設定されるべき行の[TextView2】同じ行ののvisibiltyを[ボタン]をクリックすることです[ TextView2]をView.GONEとして設定します。 [Button]をクリックすると、[TextView2]の可視性がチェックされ、現在の視認性が反対の可視性状態に変更されます。
  3. [TextView2]が表示されている場合は、およびその逆。

答えて

0

このような何かが

final Button button1 = (Button)findViewById(R.id.button1); 
    final TextView textView2 = (Button)findViewById(R.id.textView2); 
    button1.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View v) { 
      if (textView2.getVisibility() == View.VISIBLE) textView2.setVisibility(View.GONE); 
      if (textView2.getVisibility() == View.GONE) textView2.setVisibility(View.VISIBLE);    

     } 
    }); 
+0

変更textView2.VISIBLE()とそれがそうでなければ混乱を招くView.GONEとView.INVISIBLEのような定数の代わりに、0と1を使用します。 – dymmeh

0

を動作するはずです、私はあなたのための2つの質問があります:
を - あなたの活動はListActivityのですか?
- あなたのリストアダプターは何ですか?すぐに使用できますかカスタムですか?

-
訂正:textView2.getVisibilityへ

final Button button1 = (Button)findViewById(R.id.button1); 
final TextView textView2 = (Button)findViewById(R.id.textView2); 
button1.setOnClickListener(new View.OnClickListener() { 
    public void onClick(View v) { 
     if (textView2.getVisibility()== View.VISIBLE) textView2.setVisibility(View.GONE); 
     if (textView2.getVisibility()== View.GONE) textView2.setVisibility(View.VISIBLE);    

    } 
});