在android中触摸屏幕时如何添加布局?
我的要求是,无论用户在哪里触摸屏幕,我都需要显示我的布局(使用在android中触摸屏幕时如何添加布局?,android,android-layout,touch,Android,Android Layout,Touch,我的要求是,无论用户在哪里触摸屏幕,我都需要显示我的布局(使用EditText和Textview)。所以我需要做如下的事情 如何使用一个TextView和EditText 在用户触摸屏幕的次数内显示mylayout 设置触摸区域附近的布局参数 } java(我需要显示我的布局时) 在onTouch方法中。。。执行以下操作 通过id获取布局,例如 RelativeLayout RelativeLayout=(RelativeLayout)findViewById(R.id.RelativeLay
EditText
和Textview
)。所以我需要做如下的事情
TextView
和EditText
在onTouch方法中。。。执行以下操作
RelativeLayout RelativeLayout=(RelativeLayout)findViewById(R.id.RelativeLayout)
edittext
以及您想要的任何内容relativeLayout
中public class MyLayout extends LinearLayout {
private TextView myTextView;
private EditText editName;
public MyLayout(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public class MyActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
// here i need to display my layout
}
}