-2

我正在尝试通过意图将数据从一项活动发送到另一项活动。但面临强制关闭错误button click

第一个活动:

btn1= (Button) findViewById(R.id.Next);
et = (EditText) findViewById(R.id.edit); 
btn1.setOnClickListener(new Button.OnClickListener(){
   public void onClick(View v)
   {
       Intent intent = new Intent();
       intent.setClass(ViewchangerActivity.this, DisplayActivity.class);
       intent.putExtra("Name", et.getText().toString());

       startActivity(intent);
   }
});

第二个活动:

public void onCreate(Bundle savedinstanceState)
    {
        super.onCreate(savedinstanceState);
        setContentView(R.layout.main2);
        TextView tv = (TextView) findViewById(R.id.Name);
        Bundle b = getIntent().getExtras();
        String str =b.getString("Name");

         tv.setText(str);
    }

日志猫:

android.content.ActivityNotFoundException: Unable to find explicit activity class
{org.android/org.android.DisplayActivity}; have you declared this activity in your AndroidManifest.xml?
4

2 回答 2

5

确保您已在 Manifast.xml 中将DisplayActivity注册为:

<activity android:name=".DisplayActivity"></activity>

并请在 Eclipse IDE 上从Project->Clean...清理您的项目

于 2012-06-18T05:44:26.027 回答
2

您的活动未添加到清单中............

<activity android:name=".DisplayActivity"></activity>
于 2012-06-18T05:50:23.597 回答