javascript - 单击按钮时的新选项卡/删除按钮上的选项卡/单击按钮时将项目添加到选项卡
问题描述
我正在尝试在 Android Studio 中创建一个应用程序,在该应用程序中,用户可以在单击按钮时创建新选项卡......就像 chrome,但不同之处在于它们应该是永久性的,不像 chrome 选项卡,并且只能由用户在另一个按钮单击时删除,并且我想让这些新标签可自定义,以便用户也可以在其中添加新项目。到目前为止,我已经使用选项卡布局制作了 XML 布局并添加了已删除的按钮,但是我是 android 开发的新手,我不知道下一步该做什么,我学会了通过添加新片段来静态添加选项卡,但我不知道如何使其动态化,以便用户可以添加/删除新的 tabs.plz,任何帮助表示赞赏...
.java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TableLayout;
public class MainActivity extends AppCompatActivity {
TableLayout tableLayout;
Button button;
ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tableLayout.findViewById(R.id.tablayout);
button.findViewById(R.id.button1);
viewPager.findViewById(R.id.viewpager);
}
}
.Xml
<?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"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add routine"
/>
</LinearLayout>
</LinearLayout>
解决方案
推荐阅读
- python - Windows python用户的quickfix库分步成功安装
- php - 自动嵌套循环
- php - 从 WordPress DB 检查元值不适用于页面
- vue.js - 在 Vuejs 中更改 v-model 输入值时动态数据不会更新
- c# - 当我使用 invokemember () Webbrowser 按下按钮时出现错误
- ios - UINavigationView 弹出到根视图控制器问题
- php - 从 cmd 运行时,来自 WAMP 服务器的 PHP 没有看到 .htaccess 文件
- google-apps-script - 类表方法 getActiveCell、getCurrentCell、getActiveRange 无法按预期工作
- ejabberd - 如何使用 Smack Client 在 Ejabberd 中注册带内用户,特别是虚拟主机?
- javascript - 将两个代码合二为一 - 检查 url 是否存在/登录