Java android编程中的错误
这段代码中有两个问题,这实际上是一个简单的代码,目的是有一个按钮并键入一段文字,当按下按钮并转到下一个活动时,显示文字已经写好Java android编程中的错误,java,android,Java,Android,这段代码中有两个问题,这实际上是一个简单的代码,目的是有一个按钮并键入一段文字,当按下按钮并转到下一个活动时,显示文字已经写好 package com.example.mysecondapp; import android.os.Bundle; import android.app.Activity; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import and
package com.example.mysecondapp;
import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Reference from EditText
final EditText matn = (EditText) findViewById(R.id.editText1);
// Reference from Button
Button d = (Button) findViewById(R.id.button1);
d.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent mafhoom = new Intent(Main.this, Second.class);
mafhoom.putExtra("Selectedpassage", matn.getText().toString());
startActivity(mafhoom);
}
});
}
}
根据你的密码,我建议你 你应该进口
import android.content.View.OnClickListener;
而不是
import android.content.DialogInterface.OnClickListener;
或者setOnClickListener(..)
类似
d.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mafhoom = new Intent(Main.this, Second.class);
mafhoom.putExtra("Selectedpassage", matn.getText().toString());
startActivity(mafhoom);
}
});
你的第二个活动在哪里?你的错误是什么?你能显示你的日志吗?
这段代码中有两个问题。。。哪些问题?当我运行此问题时,显示OnClickLitenerSSS中的错误!非常感谢您的帮助。但是还有一个错误,当我进入文章进入下一个活动时,为了显示我之前键入的内容,出现了一个错误。