<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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" tools:context="com.texxt.MainActivity"> <LinearLayout android:id="@+id/fr" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> > <ImageView android:id="@+id/imageview" android:layout_width="50px" android:layout_height="50px"> </ImageView> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/line1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> > <TextView android:text="111111111111111" android:layout_width="match_parent" android:layout_height="wrap_content"></TextView> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/line2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> > <TextView android:text="2222222222" android:layout_width="match_parent" android:layout_height="wrap_content"></TextView> </LinearLayout>
package com.texxt; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.BaseAdapter; import android.widget.Chronometer; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.RatingBar; import android.widget.SeekBar; import android.widget.SimpleAdapter; import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import com.example.textmethod.R; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; public class MainActivity extends Activity { public TabHost tabHost; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tabHost=findViewById(android.R.id.tabhost); tabHost.setup(); LayoutInflater layoutInflater=LayoutInflater.from(this); layoutInflater.inflate(R.layout.tab1,tabHost.getTabContentView()); layoutInflater.inflate(R.layout.tab2,tabHost.getTabContentView()); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("只能设备").setContent(R.id.line1)); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("智能设备").setContent(R.id.line2)); } }