0

以下に示す次のコードでは、表示ボタンをクリックしたときに新しいアクティビティ (memo.class から view.class へ) を開こうとしていますが、「アクティビティが見つからない例外: 明示的なアクティビティ クラスが見つかりません」というエラーが表示されます。私のコードで何が間違っていますか?? 私を助けてください

私のコード:

memo.xml

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

<TextView android:text="Titile" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:id="@+id/question" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""></EditText>
<TextView android:text="Text" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:minLines="6" android:maxLines="10" android:id="@+id/answer" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""></EditText>
<TableLayout android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:layout_gravity="center"
        android:stretchColumns="*">
<TableRow>
<Button android:id="@+id/add" android:layout_width="wrap_content" android:text="ADD" android:layout_height="wrap_content"></Button>
<Button android:id="@+id/view" android:layout_width="wrap_content" android:text="VIEW" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>

memo.java

package quesansw.the1;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

public class Memo extends Activity{

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final Dialog d1 = new Dialog(this);
        Window window = d1.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

        d1.setTitle("Register Questions");

        d1.setContentView(R.layout.memo);
        d1.show();

        Button view1 = (Button) d1.findViewById(R.id.view);
        Button add = (Button) d1.findViewById(R.id.add);


        add.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v)
            {
                EditText add = (EditText) d1.findViewById(R.id.question);
                EditText view = (EditText) d1.findViewById(R.id.answer);
                System.out.println(add.getText());
                System.out.println(view.getText());


            }
          });

        view1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v)
            {
                Intent intent = new Intent(getBaseContext(), View.class);
                startActivity(intent);
            }
    });
}
}

view.xml

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

 <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="match_parent">


<EditText android:id="@+id/question" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""></EditText>
</LinearLayout>

ビュー.java

package quesansw.the1;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class View extends Activity { 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final Dialog d1 = new Dialog(this);
        Window window = d1.getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

        d1.setTitle("Login");

        d1.setContentView(R.layout.view);

        d1.show();
    }

}
4

3 に答える 3

2

マニフェストでアクティビティを宣言する必要があります。

<activity
    android:name="com.yourpackagename.View"/>

基本的に、AndroidManifest.xml ファイル (ルート パッケージ フォルダーにあります) は、アプリケーション全体の「設定」または「メイン コントローラー」として機能します。への移行または使用。

マニフェスト ファイルのアクティビティ タグ内に含めることができるその他のものを次に示します。

補足: @Tyler M. が言うように、アクティビティには「View」以外の名前を使用する必要があります。

于 2013-03-26T02:45:06.887 に答える
1

Activityサブクラスの名前を 以外の名前に変更しますView

一般に、既存のクラスの名前を使用するのは悪い考えです。これは、発生するのを待っている参照災害です。

于 2013-03-26T03:03:27.170 に答える
0

Manifest.xml に含めるのを忘れている可能性があります。

于 2013-03-26T02:45:00.403 に答える