2013-08-24 2 views
-1

이 자바 언어를 배우고 제 앱을 만들려고하는데이 메서드를 입력 할 때마다이 오류가 발생합니다. 그것은 어떻게 저에게 저 오류를 주는가? 내가 YouTube에서 트래비스에서 자습서를 따라하고 그는이 errror을하지 않습니다, 나는Eclipse android, findIdByView (int) 유형이 xxxxxxx 형식에 대해 정의되지 않았습니다.

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

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" > 
</EditText> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/tvStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.50" 
     android:gravity="center" 
     android:text="Style" 
     android:textSize="25sp" /> 

    <TextView 
     android:id="@+id/tvGravity" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.50" 
     android:gravity="center" 
     android:text="Gravity" 
     android:textSize="25sp" /> 

</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 

    <RadioGroup 
     android:id="@+id/rgStyle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.50" > 

     <RadioButton 
      android:id="@+id/rbNormal" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:text="Normal" /> 

     <RadioButton 
      android:id="@+id/rbItalic" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Italic" /> 

     <RadioButton 
      android:id="@+id/rbBold" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Bold" /> 
    </RadioGroup> 

    <RadioGroup 
     android:id="@+id/rgGravity" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.50" > 

     <RadioButton 
      android:id="@+id/rbLeft" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:text="Left" /> 

     <RadioButton 
      android:id="@+id/rbCenter" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Center" /> 

     <RadioButton 
      android:id="@+id/rbRight" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Right" /> 
    </RadioGroup> 
</LinearLayout> 

<TextView 
    android:id="@+id/tvChange" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:text="Generate here" /> 

<Button 
    android:id="@+id/bGenerate" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Generate" 
    android:textSize="25sp" /> 

</LinearLayout> 
+1

농담입니까? findIdByView .. 그냥 findViewById ... Android에서 프로그램을 시작하기 전에 읽으십시오. http://developer.android.com/reference/android/widget/Button.html – Amsheer

답변

2

다음 줄을 교체하십시오

package com.nichlas.denfoerste; 


import android.app.Activity; 
import android.os.Bundle; 
import android.widget.EditText; 
import android.widget.RadioGroup; 
import android.widget.RadioGroup.OnCheckedChangeListener; 
import android.widget.TextView; 

public class TutorialOne extends Activity implements OnCheckedChangeListener{ 

TextView textOut; 
EditText textIn; 
RadioGroup gravityG, styleG; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.tutorial1); 
    textOut = (TextView) findIdByView(R.id.tvChange); 

} 


@Override 
public void onCheckedChanged(RadioGroup arg0, int arg1) { 
    // TODO Auto-generated method stub 

} 
} 

내 XML 파일 ..이 알아낼 수 없습니다 .

textOut = (TextView) findViewById(R.id.tvChange); 
+0

정말 고마워요. . : D HAHA .. 나 얼마나 어리 석 었니 ... 때로는 새로운 눈으로도 도움이된다.;) – Niller

0
textOut = (TextView) findIdByView(R.id.tvChange); 

textOut = (TextView) findIdByView(R.id.tvChange); 

은 노호 라인이 교체 ...

textOut = (TextView) findViewById(R.id.tvChange); 

그리고 당신이 완료됩니다.

관련 문제