在我的应用程序中,我想在 android 应用程序 TextViews 上显示保存在 MY_SQL 中的数据。我该怎么做
我的 android 应用程序布局是:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cus_name"
android:gravity="center"
android:clickable="true"
android:focusable="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/cus_name_txta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/contact_no"
android:clickable="true"
android:focusable="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/contact_no_txta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ticket_no"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/ticket_no_txta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
<requestFocus />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="@string/task_detail"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/task_detail_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/attend_by"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/attend_by_txta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
我的Java代码是:
public static String attend_by_txt;
TextView cus_name_txt, contact_no_txt, ticket_no_txt;
TextView task_detail_txt;
EditText attend_by_txtbx;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_task);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
cus_name_txt = (TextView)findViewById(R.id.cus_name_txta);
contact_no_txt = (TextView)findViewById(R.id.contact_no_txta);
task_detail_txt = (TextView)findViewById(R.id.task_detail_txt);
当我点击 customer_name、Contact_No、ticket_No、Task_detail 时,我想要那个。它显示保存在 MY_SQL 中的数据。请指导我如何从数据库中检索数据并将其显示在 android 中。我会非常感谢你。