Android studio如何增加和设置菜单menu

Android studio如何增加和设置菜单menu
https://jingyan.baidu.com/article/73c3ce28345acbe50243d94e.html
https://www.cnblogs.com/HDK2016/p/8038908.html

https://jingyan.baidu.com/article/8275fc86b8a76d46a13cf654.html
https://blog.csdn.net/qq_38228830/article/details/80851532

TabActivity
import androidx.appcompat.app.AppCompatActivity;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
    private TabHost tabHost;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //从TabActivity上面获取放置Tab的TabHost
        tabHost =  (TabHost)findViewById(R.id.tabHost);
        tabHost.setup();
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("标签页一").setContent(R.id.tab1));
        tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("标签页二").setContent(R.id.tab2));
        tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("标签页三").setContent(R.id.tab3));
    }
}
 

你可能感兴趣的:(TEST)