1

私はAndroidアプリを開発しています, これは私の最初のアプリ開発です,

私の要件に従って、以下の画像のように UI を実装するコードが必要です。

画像をホッピングすると、私の要件が説明されます。下の画像はアプリ UI ビューです。ありがとう..

ここに画像の説明を入力

以下のコードを使用しましたが、機能していません。誰でも欠点を見つけることができます..

 - DrinkActivity.java

TextView t ;
public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_drink);
            t = (TextView)findViewById(R.id.TextView01);
            t.setOnClickListener((android.view.View.OnClickListener) this);
            }
public void onClick(View arg0) {
            t.setText("My text on click");  
            }

 - activity_drink.xml


<LinearLayout 
    android:id="@+id/LinearLayout01" 
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content">

</LinearLayout>

<ListView
    android:id="@+id/ListView01"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" >
</ListView>
<LinearLayout 
    android:id="@+id/LinearLayout02" 
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content">

</LinearLayout>

<TextView android:text="This is my first text"
 android:id="@+id/TextView01" 
 android:layout_width="wrap_content" 
 android:textStyle="bold"
 android:textSize="28sp"
 android:editable="true"
 android:clickable="true"
 android:layout_height="wrap_content"
 android:onClick="onClick">

 </TextView>
4

1 に答える 1

0

2 つのフラグメントを設計することで、この動作を実現できます。

1.最初のものは、タブ テキストのみを表示する単純な TextView フラグメントになります。

2. 2 番目のフラグメントは、2 つの TextView を次々に含む LinaerLayout 垂直レイアウトになります。最初のフラグメントは最初のフラグメントと同じ TextView になり、2 番目の TextView にはタブの説明が含まれます。

次に、最初のフラグメントをクリックして、次のコードを使用して2番目のフラグメントに置き換えます。

 if (!isTabOpen)
 {
     fragmentTransaction = fragmentManager.beginTransaction();
     fragmentTransaction.remove(TabFragment)
     .add(R.id.containerForFragments,TabAndDescriptionFragment)
     .commit();
 }
 else
 {
      fragmentTransaction = fragmentManager.beginTransaction();
     fragmentTransaction.remove(TabAndDescriptionFragment)
     .add(R.id.containerForFragments,TabFragment)
     .commit(); 
 }

plusButtonFragment と userNewFragment を作成した後。

于 2013-03-04T18:57:26.600 に答える