2012-02-10 9 views
-3

私のアプリケーションは動作しませんが、開発にエラーメッセージは表示されません。 私のページを別のページにリンクする方法を学んでいます。Android eclipse。アプリケーションを実行しているときにエラーが発生しました

enter image description here

TMactivityページ1

public class TmActivity extends Activity { 

    private ImageButton NewPage; 

    /** Called when the activity is first created. */ 

    @Override 

    public void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 

    this.setContentView(R.layout.main); 

    this.NewPage = (ImageButton)this.findViewById(R.id.widget38); 

    this.NewPage.setOnClickListener(new OnClickListener() { 



public void onClick(View WebView) { 

Intent i = new Intent(TmActivity.this, New.class); 

startActivity(i); 

} 

}); 

} 

} 

// 2ページ:

public class WebView extends Activity { 

     public class New extends Activity { 

      /** Called when the activity is first created. */ 

      @Override 

      public void onCreate(Bundle savedInstanceState) { 

      super.onCreate(savedInstanceState); 

      setContentView(R.layout.web); 

      } 

      } 
    } 

//最初のxml:

<?xml version="1.0" encoding="utf-8"?> 
    <AbsoluteLayout 
     android:id="@+id/widget0" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 
    <ImageButton 
     android:id="@+id/widget37" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="#FFFFFF" 
     android:layout_x="4dp" 
     android:layout_y="387dp" /> 
    <ImageButton 
     android:id="@+id/widget38" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="69dp" 
     android:layout_y="386dp" /> 
    <ImageButton 
     android:id="@+id/widget39" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="151dp" 
     android:layout_y="386dp" /> 
    <ImageButton 
     android:id="@+id/widget40" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_x="242dp" 
     android:layout_y="383dp" /> 
    <TextView 
     android:id="@+id/widget43" 
     android:layout_width="wrap_content" 
     android:layout_height="47px" 
     android:background="#FF0000" 
     android:text="Teknikmagasinet" 
     android:textSize="20sp" 
     android:typeface="sans" 
     android:textStyle="bold" 
     android:textColor="#FFFF00" 
     android:layout_x="74dp" 
     android:layout_y="11dp" /> 
    <TextView 
     android:id="@+id/widget44" 
     android:layout_width="203px" 
     android:layout_height="30px" 
      android:text="nyheter" 
     android:textColor="#FFFF00" 
     android:layout_x="34dp" 
     android:layout_y="77dp" /> 
    <ImageView 
     android:id="@+id/widget45" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="#ff33cc00" 
     android:layout_x="44dp" 
     android:layout_y="143dp" /> 
    <TextView 
     android:id="@+id/widget46" 
     android:layout_width="wrap_content" 
     android:layout_height="47px" 
     android:background="#ffcc6600" 
     android:text=" emil bergstrlm han &#228;r kung " 
     android:hint="phuong" 
     android:layout_x="13dp" 
     android:layout_y="255dp" /> 
    </AbsoluteLayout> 

// 2番目のxml:

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    package="tm.com" 

    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" 
    /> 

    <ImageButton 
     android:id="@+id/widget38" 
     android:layout_width="150dp" 
     android:layout_height="wrap_content" /> 

    <Button 
    android:text="Second Page" 
    android:id="@+id/close" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"></Button> 

    </LinearLayout> 

    sting xml: 
    <?xml version="1.0" encoding="utf-8"?> 
    <resources> 

     <string name="hello">Hello World, TmActivity!</string> 
     <string name="app_name">Tm.com</string> 
     <string name="main_title">My Main Title</string> 
    </resources> 

ありがとうございました!

+0

コードの代わりに、エラーログを送信する必要があります。 –

+3

あなたの活動をあなたのmanifest.xmlファイルに登録するのを忘れたと思います。 –

+0

open terminalに 'adb locat'と入力してエラーを見つけてください(エラーは" E/"で始まります)。ターミナルを開いて 'adb logcat'と入力して、アプリケーションを起動しようとすると(ターミナルが開いている)、エラーの発生場所を見ることができます。 –

答えて

0

// 2番目の活動

public class WebView extends Activity { 

からこの生活を削除し、あなたのmanifest.xmlに

+0

用CET 2012 パーサ例外をeclipse_keyring /Users/zamilio/Documents/workspace/tm/AndroidManifest.xmlのパーサー例外:要素タイプ "application"の後には、属性指定 ">"または "/>"のいずれかが続かなければなりません。 [2012-02-10 17:08:29 - tm] XMLファイルのエラー:ビルドを中断しています。 [2012-02-10 17:11:53 - tm] XMLファイルのエラー:ビルドを中止します。 – Emil

0

私が正しく理解していれば、あなたはすでに実行しているから、新たな活動を開くしようとしている新規登録アクティビティ(あなたのページを切り替える)?これを試して。

活性Main.java:

package tm.com 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 

public class TmActivity extends Activity { 
    /** Called when the activity is first created. */ 
     @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     final Button butn = (Button) findViewById(R.id.button1); 

     butn.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View v) { 
       Intent intent = new Intent(TmActivity.this, New.class); 
       startActivityForResult(intent, 0); 
      } 
     }); 
    } 
} 

レイアウトMain.xml:アプリケーションマニフェストに

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <Button android:id="@+id/button1" android:text="name" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> 
</RelativeLayout> 

*のようになり、アプリケーション・ブラケットのマニフェストを変更。

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".TmActivity" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity>  
     <activity android:name=".New"></activity> 
</application> 
+0

02-10 17:26:38.690:D/dalvikvm(538):CheckJNIが有効になっていません(既にオン) 02-10 17:26:39.580:D/AndroidRuntime(538):VMをシャットダウン 02-10 17:26:39.580:threadid = 1:キャッチされない例外(グループ= 0x409c01f8)でスレッドが終了する 02-10 17:26:39.610:E/AndroidRuntime(538):致命的例外:メイン 02 -10 17:26:39.610:E/AndroidRuntime(538):java.lang.RuntimeException:アプリケーションtm.com.Mainをインスタンス化できません:java.lang.ClassNotFoundException:tm.com.Main 02-10 17:26: 39.610:E/AndroidRuntime(538): – Emil

+0

'Main'はあなたのクラスの名前に置き換えられ、ダミーの名前としてそこに置きます。' TmActivity'で置き換えることができます。 'android:name =" Main "'、 'Intent(Main.this、..);'など – gkiar

+0

私はhaに編集しましたマニフェストとJavaクラスの両方であなたの活動の名前を指定してください。 – gkiar

関連する問題