View indexView = View.inflate(this,R.layout.index,null);
ImageButton imageButtonWifi = indexView.findViewById(R.id.wifi);
imageButtonWifi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("Tag","66666");
}
});
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:id="@+id/index">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#0066FF"
>
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@drawable/logo"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_centerInParent="true"
android:id="@+id/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="XXXX大学"
android:textColor="#ffffff"
android:layout_toRightOf="@+id/icon"
android:layout_centerInParent="true"
android:layout_marginLeft="10dp"/>
<ImageButton
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/scan"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="75dp"
android:orientation="horizontal"
android:background="#0066FF">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/wifi"
android:layout_centerHorizontal="true"
android:id="@+id/wifi"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校园网认证"
android:textColor="#ffffff"
android:layout_below="@+id/wifi"
android:layout_centerInParent="true"
android:textSize="12dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/timetable"
android:layout_centerHorizontal="true"
android:id="@+id/timetable"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="课表"
android:textColor="#ffffff"
android:layout_below="@+id/timetable"
android:layout_centerInParent="true"
android:textSize="12dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/helper"
android:layout_centerHorizontal="true"
android:id="@+id/helper"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="班委助手"
android:textColor="#ffffff"
android:layout_below="@+id/helper"
android:layout_centerInParent="true"
android:textSize="12dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/application"
android:layout_centerHorizontal="true"
android:id="@+id/application"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="其它应用"
android:textColor="#ffffff"
android:layout_below="@+id/application"
android:layout_centerInParent="true"
android:textSize="12dp"/>
</RelativeLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="66666"
android:id="@+id/textBtn"/>
</LinearLayout>
另外textBtn点击也没有响应。