在我的应用程序中,我必须显示一些 3 个编辑文本视图和 3 个文本视图,基于某些条件(即)如果它满足某些条件,则应该显示,否则它不应该显示。我在 xml 文件中有这个文本视图。我怎样才能做到这一点..提前致谢:
我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item"
android:layout_marginLeft="10dp"/>
<EditText
android:id="@+id/itemedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price"
android:layout_marginLeft="10dp"/>
<EditText
android:id="@+id/priceedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="decimal"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView -------->TExtview1
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Type"
android:layout_marginLeft="10dp"/>
<TextView --------->TExtview2
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Recurrence"
/>
<TextView --------->TExtview3
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Start Date"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<EditText --------->edittext1
android:id="@+id/recccatedit"
android:layout_width="110dp"
android:layout_height="wrap_content"
/>
<EditText --------->edittext2
android:id="@+id/reccedit"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:numeric="decimal"
/>
<EditText --------->edittext1
android:id="@+id/reccdateedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="right"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/btndelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Delete" />
</LinearLayout>
</LinearLayout>
我的java类文件:
if(!reccinc.equals("0"))
{
System.out.println("Inside if");
EditText rec=(EditText)findViewById(R.id.reccedit);
EditText reccdate=(EditText)findViewById(R.id.reccdateedit);
EditText recctype=(EditText)findViewById(R.id.recccatedit);
String recc=null;
String date=null;
String type=null;
db.open();
if(!intent.getStringExtra("Recc").equals("0"))
{
Cursor c= db.getReccurenceCount(intent.getStringExtra("Recc"));
startManagingCursor(c);
recc=c.getString(c.getColumnIndex("increment"));
date=c.getString(c.getColumnIndex("startdate"));
type=c.getString(c.getColumnIndex("recurrencetype"));
}
rec.setText(recc);
recctype.setText(type);
reccdate.setText(date);
}