テキストを動的に表示したいのですが、テキストを表示したいのですが、「表示>」ボタンをクリックすると、テキストがボックスに表示されます。
私が試したのは、2つのテキストビューを使用してそれを行うことです。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="2dip"
android:text="some text"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="view >>"
android:textSize="9sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="2dip"
android:text=" yes"
android:textSize="11.0sp"
android:visibility="invisible" />
</RelativeLayout>
コード:
public void onClick(View v)
{
switch(v.getId())
{
case R.id.button1:
tv1.setVisibility(View.VISIBLE);
break;
}
}
何が起こったのかというと、2番目のテキストビューが最初のテキストビューにテキストを表示しているということです。では、このようなテキストを表示することは可能ですか?そうでなければ、混乱したテキストビューを克服するために何をすべきですか?