0
動態視圖我有同樣的問題作爲這一adding views dynamically添加android系統
我創建一個應用程序採用了android標記的圖像照片。
所以一旦我點擊一個位置,我需要創建一個EditText,我可以鍵入。
我能夠做到這一點,但問題是當我編輯edittext時,它不會使已經存在的數據無效。它與之前存在的數據重疊。
這裏是我膨脹並添加
public boolean onTouch(View v, MotionEvent event) {
//.....
frmLayout = (FrameLayout)findViewById(R.id.frameLayout);
frmLayout.setFocusable(true);
mInflater = LayoutInflater.from(getApplicationContext());
View view = mInflater.inflate(R.layout.tag_layout,null);
view.setX(event.getX());
view.setY(event.getY());
frmLayout.addView(view,250,250);
//....
}
tag_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:layout_alignParentLeft="true"
android:id="@+id/edittext1"
android:textColor="@android:color/black"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edittext2"
android:layout_toRightOf="@id/edittext1"
android:text="D"
/>
</AbsoluteLayout>
TIA
就像在這裏註釋.. AbsoluteLayout已被棄用。你應該使用一些其他的佈局..只要這不是造成這個問題無論如何。 –
@AndroSelva我想在他點擊的位置創建一個新的視圖。所以我去了絕對。有沒有其他的佈局,當我可以創建一個特定的(x,y) – siva
可能是一個框架佈局.. –