2012-12-15 2 views
0

나는 인터넷에서 샘플과 코드로 내 안드로이드 애플 리케이션을 해결하려고 노력 해왔다. 같은 대한첫 번째 타이머 android development

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:gravity="center" 
    android:padding="10dip"> 
    <Button 
     android:id="@+id/brew_time_down" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="-" 
     android:textSize="40dip" /> 
    <TextView 
     android:id="@+id/brew_time" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="0:00" 
     android:textSize="40dip" 
     android:padding="10dip" /> 
    <Button 
     android:id="@+id/brew_time_up" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="+" 
     android:textSize="40dip" /> 
    </LinearLayout> 

자바 코드 - 그들을 따라 나는 코드

**Button brewAddTime = (Button) findViewById(R.id.brew_time_up);** 

이 부분에 대한 XML의 줄을 다음과 같은 오류

**"Brew_Time_Add cannot be resolved or is not a field."** 

있어 -

protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     Button brewAddTime = (Button) findViewById(R.id.brew_time_up); 
     Button brewDecreaseTime = (Button) findViewById(R.id.brew_time_down); 
      Button startBrew = (Button) findViewById(R.id.brew_start); 
      TextView brewCountLabel = (TextView) findViewById(R.id.brew_count_label); 
      TextView brewTimeLabel = (TextView) findViewById(R.id.brew_time); 

    } 

왜 오류가 있으며 어떻게 해결 될 수 있습니까?

사전에 http://db.tt/kbjq6u5o

감사 AT- 이미지를 참조하시기 바랍니다.

+1

layout.xml 파일에 'brew_time_up'을 추가 했습니까? 또한 이미지에 표시하는 대신 질문에 코드를 추가하십시오. –

+0

@codingcrow 지금 확인하고 도움하십시오. 이것 없이는 앞으로 나아갈 수 없다. –

+0

Logcat에있는 오류를 붙여넣고 @bodge 대답을 보았습니까? –

답변

0

레이아웃에 그런 이미지가 있습니까? 그런 다음 프로젝트를 저장하고 청소 한 경우

프로젝트가 준비되었습니다.> 청소하려면 청소하십시오.

0

당신은 레이아웃에 XMLS 선언을 누락 - XMLNS를 추가 : 안드로이드 = "http://schemas.android.com/apk/res/android"레이아웃에,과 같이 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:gravity="center" 
android:padding="10dip"> 
<Button 
    android:id="@+id/brew_time_down" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="-" 
    android:textSize="40dip" /> 
<TextView 
    android:id="@+id/brew_time" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="0:00" 
    android:textSize="40dip" 
    android:padding="10dip" /> 
<Button 
    android:id="@+id/brew_time_up" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="+" 
    android:textSize="40dip" /> 

brew_start와 brew_count_label 모두 xml에 없기 때문에 오류가 계속 발생하지만 마찬가지입니다.

0

레이아웃 파일에 추가하십시오. 레이아웃 파일에 다음 두 요소가 없습니다.

<TextView 
android:id="@+id/brew_count_label" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="0:00" 
android:textSize="40dip" 
android:padding="10dip" /> 
<Button 
android:id="@+id/brew_start" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Start" 
android:textSize="40dip" />