2012-12-20 3 views
0

여기안드로이드 코딩 힘은 가까운

도와주세요 난 임의 함수 나의 setText 응용 프로그램 강제 닫히고을 사용하지 않은 경우에도 사용하고있는 코드 AVD 여기

public class MainActivity extends Activity { 


Button magic; 
TextView display; 
int random; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 


    magic=(Button)findViewById(R.id.magic); 
    display=(TextView)findViewById(R.id.textView1); 
    magic.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      random = (int)Math.ceil(Math.random()*100); 

      display.setText("your number is"+random); 

     } 
    }); 

    } 
} 

에서 실행 힘 가까운 오류를주고있다 코드입니다 오류 또는 경고를 포기하지 않을

activity_main.xml ..........

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:background="@drawable/magic8ball" 
    android:gravity="center" 
    tools:context=".MainActivity" > 

    <android.widget.Space 
     android:id="@+id/space1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="144dp" 
     android:layout_marginTop="192dp" /> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="131dp" 
     android:layout_marginTop="171dp" 
     android:orientation="vertical" > 
    </LinearLayout> 

    <Button 
     android:id="@+id/magic" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/linearLayout1" 
     android:layout_toRightOf="@+id/linearLayout1" 
     android:text="@string/Magic" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/Magic" 
     android:layout_alignParentRight="true" 
     android:layout_marginBottom="64dp" 
     android:layout_marginRight="74dp" 
     android:text="@string/Ask" 
android:textAppearance="?  android:attr/textAppearanceLarge" 
     android:textColor="#EE5533" /> 

</RelativeLayout> 
하드

텍스트가 string.xml 또는 하드 코드 그것에으로 설정하는 것이 좋다 여부를 변경하는 것입니다 때문에

을 코딩 할 때 하나의 경고의이 textview1 관련된다

xml 파일이 제공됩니다 ?????

+6

사용 로그 캣 이해 ... 그게 사용할 수없는 코드 생각 볼 수없는 것 같다 –

+1

logcat 게시 –

+1

일부 로그/스택 추적을 게시하십시오 ... –

답변

0

다음 코드를 어떤 용도로 사용하고 있습니까?

**<android.widget.Space 
     android:id="@+id/space1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="144dp" 
     android:layout_marginTop="192dp" />** 

이 무슨 .. 그것 ICS 장치에서 잘 작동 ..하지만 진저 브레드 기기에서 작동하지 않습니다 .. 내가

+0

덕분에 문제를 RAJESH 한 번 해결 나는이 코드를 제거한다. – tusharm

관련 문제