2016-06-14 28 views
-2

我想給id作爲@android:id/kish但它表明沒有資源發現在給定的名字相匹配(在與值「身份證」「@android:ID /基什」)

沒有資源發現在給定的名字相匹配(在'id',值爲'@android:id/kish')。

但上述@android:id/text1工作

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/content" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <!-- Dummy content. --> 
      <LinearLayout android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:padding="16dp"> 

       <TextView android:id="@android:id/text1" 
        style="?android:textAppearanceLarge" 
        android:textStyle="bold" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="16dp" /> 
       <TextView android:id="@android:id/kish" 
        style="?android:textAppearanceLarge" 
        android:textStyle="bold" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="16dp" /> 



      </LinearLayout> 

     </ScrollView> 

IMAGES

xml errorpic
The run time error

回答

3

@android:ID/text1爲在ids.xml已定義。 ids.xml通常用於聲明您在佈局中用於視圖的標識。
所以,你必須聲明你@android:id/kish在ids.xml
或者你可以聲明這樣android:id="@+id/kish"

+0

哪個文件我shuld申報android:id =「@ + id/kish」 –

+0

你必須聲明這個@android:id/kish在你的佈局:) –

+0

@Rahulkishan ....快樂編碼親愛的.... :) –

0

如果動態地創建視圖,預定義的ID在ids.xml給人以引用的可能性新創建的視圖。在使用setId(id)方法後,您可以像訪問XML一樣訪問該視圖。這是您可以從此路徑「USER_DIRECTORY/android-sdk/platforms/android-23/data/res/values/ids.xml」中找到的Android的默認ID,其中@android:id/text1也是其中的一部分。所以,如果你想爲任何視圖賦予id而不是使用它,請使用下面的代碼來分配id。

android:id="@+id/textView" 
+0

對不起,我真的不明白的地方的路徑是初始化id..can你寄我scrren出手吧 –

+0

要在你的視圖中使用,你可以使用,如我所說的,'android:id =「@ + id/textView」' –

相關問題