【发布时间】:2014-07-02 16:26:31
【问题描述】:
所以我正在开发一个 Android 应用程序(在 Eclipse 中)并且我碰壁了。在我的应用程序中,我有一个抽屉滑出选项列表。我希望用户能够单击其中一个选项并打开一个带有表单的浮动窗口。我正在尝试使用按钮上的 onClick 属性而不是使用 onClickListener 来执行此操作。这是否可能无需使用 onClickListener 或者我是否试图避免不可避免的情况?我的布局中按钮的 onClick 属性的值为“newWindow”。
我的 MainActivity 类
public void newWindow(View v){
Intent intent = new Intent(){
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
};
startActivity(intent);
}
我看到我的 popupView 变量未使用,但我不确定该放在哪里,或者我是否朝着正确的方向前进。提前感谢您的帮助!
【问题讨论】:
-
我能想到的最简单的选项是“对话”。无论是用户输入还是通知都可以解决问题。然后转到片段。不过,开始这样的活动看起来并不漂亮。
标签: java android xml eclipse android-intent