2014-03-29 25 views
-4

我很biginner所以我生了請如何使用記事本進行textview?

我在我的項目中的兩個活動

首先是text1.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".Text1" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="36dp" 
     android:text="Button1" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/button2" 
     android:layout_below="@+id/button2" 
     android:layout_marginTop="82dp" 
     android:text="Button3" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/button1" 
     android:layout_below="@+id/button1" 
     android:layout_marginTop="70dp" 
     android:text="Button2" /> 

</RelativeLayout> 

和第二是text2.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="28dp" 
     android:text="TextView" /> 

</RelativeLayout> 

我想把3記事本放在我的項目中,當用戶按下text1.xml中的第一個按鈕時,在text2.xml中的textview中顯示的第一個記事本以及當用戶按下secon時在text1.xml中的第二個按鈕,在text2.xml中的textview中顯示的第二個記事本,以及像第一個和第二個第三個記事本一樣..... 如何將記事本中的文本添加到textview ,,,,什麼是代碼? 我應該在哪裏添加我的筆記本在我的項目中?資產?

+0

你可以再次使用相同的活動,並且可以創造出許多活動。 – KOTIOS

+0

是的...我只是活動....第一個是我的按鈕和第二個textview ......我如何添加文本記事本textview?什麼是代碼? – user3410344

+0

我的意思是隻讀數據從任何你想要的只是使用setText方法來設置文本到textview – KOTIOS

回答

0

您可以使用framelayout/relativelayout將所有記事本放在彼此的上面,並使用按鈕切換特定佈局的可見性。