如何解决卡片查看操作对点击卡片无响应
我设计了一个android界面,允许用户从显示的菜单项列表中选择一个动作。
但是,即使定义了必须在LoadDashboard.Java
这是我的xml文件名fragment_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);
}
});
}}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。