按钮显示在调试中,但在 Eclipse for Android 上常规运行应用程序时不显示
我有一个最近才开始出现的奇怪问题。当我从 Eclipse 正常运行应用程序时,我的按钮不会显示在主屏幕上(但是,如果我单击它们应该在的位置,它会注册事件)。但是当我使用调试模式启动应用程序时,按钮显示在它们应该在的位置!这是没有更改代码的情况。这两个按钮也被设置为在布局中“可见”。
有谁知道这是为什么吗?我从主屏幕粘贴了相关代码,我注释掉了其他所有内容......
package com.android.market.companionpushup;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainScreen extends Activity {
public static String mWorkout;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainscreen);
// Create database helper
// mDbHelper = new WorkoutDbAdapter(this);
createAndRegisterButtons();
}
private void createAndRegisterButtons() {
Button GoButton = (Button)findViewById(R.id.start);
Button TestButton = (Button)findViewById(R.id.test);
GoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// int workout = chooseWorkout();
// startWorkout(workout);
} // end onClick
}); // end of GoButton
TestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// startWorkout(100);
} // end onClick
}); // end of TetsButton
} // end of createAndRegisterButtons
//
}
I have a weird problem that only started recently. When I run the app normally from eclipse, my buttons don't show up on the main screen (however if I click where they are supposed to be, it registers the event). But when I start the app using the debug mode, the buttons show up right where they are supposed to be! This is with no changes in code. Both buttons are also set to be "visible" in the layout.
Anyone know why this is? I pasted the relevant code from my main screen, I commented everything else out...
package com.android.market.companionpushup;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainScreen extends Activity {
public static String mWorkout;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainscreen);
// Create database helper
// mDbHelper = new WorkoutDbAdapter(this);
createAndRegisterButtons();
}
private void createAndRegisterButtons() {
Button GoButton = (Button)findViewById(R.id.start);
Button TestButton = (Button)findViewById(R.id.test);
GoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// int workout = chooseWorkout();
// startWorkout(workout);
} // end onClick
}); // end of GoButton
TestButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// startWorkout(100);
} // end onClick
}); // end of TetsButton
} // end of createAndRegisterButtons
//
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后重启电脑和手机就可以了。
Ended up restarting the computer and phone and it worked.