【发布时间】:2017-08-14 05:22:17
【问题描述】:
我正在创建一个文字游戏应用程序,我创建了一个由按钮组成的网格视图。当我单击网格视图中的按钮时,会打开一个弹出窗口,其中包含所有英文字母。现在,当我单击弹出窗口中的任何字母时,我希望该字母出现在我的网格中,即弹出窗口按钮中的字符串必须出现在我的网格视图的按钮中。 ,我该怎么做?
这是我的按钮代码:
button1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View container = layoutInflater.inflate(R.layout.activity_popup,null);
popupWindow = new PopupWindow(container,800,1100,true);
popupWindow.showAtLocation(constraintLayout, Gravity.NO_GRAVITY,150,400);
b1=(Button) findViewById(R.id.b1);
String s1 = b1.getText().toString();
button1.setText(s1);
container.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionevent){
popupWindow.dismiss();
return true;
}
});
}
});
我的弹窗代码:
b1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String s1 = "A";
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
finish();
}
});
应用截图
This is my grid layout where the user must enter the letters
When I click any button on the grid this is the pop up window which is displayed.
如果我运行它,应用程序将停止。
【问题讨论】:
-
添加你的错误日志
-
添加你的 logcat。
-
我是Android开发的新手,所以请详细解释一下。
标签: android