我设计了一个android界面,允许用户从显示的菜单项列表中选择操作。但是,即使在定义了必须加载这些操作的类之后,也不会发生任何操作 LoadDashboard.Java
这是我的xml文件名fragment\u dashboard.xml。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cm_background_color"
android:gravity="center_horizontal"
android:orientation="horizontal"
tools:context=".LoadDashboard">
<LinearLayout
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="false"
android:layout_marginTop="0dp"
android:background="@color/textColorWhite"
android:orientation="vertical">
<TableLayout
android:id="@+id/dashboardTable"
android:layout_width="match_parent"
android:layout_marginTop="50dp"
android:layout_height="match_parent">
<TableRow
android:id="@+id/firstRow"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:id="@+id/searchPatientCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="8dp"
android:clickable="true"
android:layout_weight="1">
<RelativeLayout
android:id="@+id/findPatientView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true">
<ImageView
android:id="@+id/findpatienticon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:contentDescription="@string/logo_desripion"
android:src="@drawable/find_patient_search" />
<TextView
android:id="@+id/findPatient"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/findpatienticon"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="15dp"
android:text="Find Patient"
android:textSize="18sp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
<!-- first element of the row-->
</TableRow>
</TableLayout>
</LinearLayout>
</RelativeLayout>
这里是应该具有该操作的java文件loaddashboard.java。
package org.ugandaemr.mobile;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
public class LoadDashboard extends AppCompatActivity {
public Context _context;
public CardView searchPatient,fetch_patient,work_summary,settings,aboutus,frequently_asked_questions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_dashboard);
searchPatient=findViewById(R.id.searchPatientCard);
searchPatient.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(LoadDashboard.this,org.ugandaemr.mobile.FindPatient.class);
Log.e("Break Point", String.valueOf(R.id.searchPatientCard));
startActivity(intent);
}
});
}}
暂无答案!
目前还没有任何答案,快来回答吧!