0

私はすでに他の質問で答えを探していますが、見つけられなかったか、見られませんでした。助けてくれてありがとう。

これらは Log Cat に表示されるエラーです

E/Trace(1417): error opening trace file: No such file or directory (2)

 E/AndroidRuntime(1417): java.lang.RuntimeException: Unable to start activity ComponentInfo{gabrielrojas.com/gabrielrojas.com.primeraventana}: android.view.InflateException: Binary XML file line #7: Error inflating class textview

 E/AndroidRuntime(1417): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class textview

アンドロイドマニフェスト

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".PruebaNumero3"
android:label="@string/title_activity_prueba_numero3" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".primeraventana"/>
<activity android:name=".segundaventana" />
</application>
</manifest>

PruebaNumero3.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" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".PruebaNumero3" />
<Button android:id="@+id/boton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Primera_Ventana"/>

<Button
android:id="@+id/boton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:text="@string/Segunda_Ventana" />

</RelativeLayout>

PruebaNumero3.java

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_prueba_numero3);
// Visualizamos Los botones
Button boton1 = (Button) findViewById(R.id.boton1);
Button boton2 = (Button) findViewById(R.id.boton2);

// Fijamos los eventos que haran ir a las otras actividades

boton1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(PruebaNumero3.this, primeraventana.class);
startActivity(intent);
}} );

boton2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(PruebaNumero3.this, segundaventana.class);
startActivity(intent); 
}} );} 



@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_prueba_numero3, menu);
return true;
} } ; 

プライマヴェンタナ.xml

<?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" >

<textview android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Escala_Uno"/>

<Button android:id="@+id/boton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Menú_Principal"/>

</LinearLayout>

プライマーaventana.java

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.primeraventana);


TextView text = (TextView) findViewById(R.id.textview1);
Button boton3 = (Button) findViewById(R.id.boton3);

text.setText(R.string.Escala_Uno);

boton3.setText(R.string.Menú_Principal);


boton3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish();

セグンダヴェンタナ.xml

<?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" >

<textview android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Escala_Dos"/>

<Button android:id="@+id/boton4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Menú_Principal"/>
</LinearLayout>

segundaventana.java

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.primeraventana);


TextView text = (TextView) findViewById(R.id.textview2);
Button boton4 = (Button) findViewById(R.id.boton4);

text.setText(R.string.Escala_Dos);
boton4.setText(R.string.Menú_Principal);


boton4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish ();
4

2 に答える 2

1

何が問題なのか正確にはわかりませんが、試してみることができることがいくつかあります。

1) primeraventana.xml では、TextView のスペルを大文字にする必要があります。そのようです:

<TextView android:id="@+id/textview1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/Escala_Uno"/>

2) segundaventana.java では、文字列名は英字と数字のみにすることができます。次の「ú」を削除します。

boton4.setText(R.string.Menú_Principal);

最後に、次のように OnClickListeners() を宣言します。

button.setOnClickListener(new View.OnClickLister() {
    public void onClick(View v) {
        // You code here.
    }
}

ビューがないことに違いをもたらす天気はわかりません。見栄えが良くなります。:)

于 2013-01-16T08:00:11.977 に答える
1

primeraventana.xmlレイアウト ファイルを確認します。TextView存在しないテキストビューでタグを開きました。以下のように変更します

<?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" >

<TextView android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Escala_Uno"/>

<Button android:id="@+id/boton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Menú_Principal"/>

</LinearLayout>
于 2013-01-16T07:49:19.510 に答える