Android netbeans textchange按钮点击
问题描述:
这可能很简单,但我创建了一个简单的应用程序,单击按钮时可以更改文本视图的文本。这些应用程序正确调试,但不显示更改。Android netbeans textchange按钮点击
实际发生的是这样的。
应用程序调试OK
仿真器显示 “等待调试器附加”
文本不会更改的按钮点击
答
确保你已经写button_name.setOnClickListener(this);
如果您Activity
正在实施onClickListener
。
你应该这样做。
package org.sample;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Hello extends Activity {
private Button button;
private TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button);
text = (Button) findViewById(R.id.text1);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
text.setText("Something....");
}
});
}
}
您需要像下面那样运行应用程序。
你可以编辑你的问题,并添加不工作的代码? (您的主要活动)我们需要更多信息来帮助您。 –
'Apps debug OK'是什么意思? “等待调试器连接”实际上是否连接调试器,还是在那里挂?因为@TimothéeJeannin提到:没有进一步的信息没有人能够帮助你 –