Android 如何从数据库(REST)查看数据

Android 如何从数据库(REST)查看数据,android,android-studio,Android,Android Studio,我已经使用android studio在我的应用程序中完成了底部导航。所以,我想在我的一个片段中创建一个按钮。我怎么做?有视频参考吗?谢谢。这很容易,也不难,只需在片段布局中放置按钮,然后在片段中创建实例后,为特定按钮(如bellow)放置侦听器 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.and

我已经使用android studio在我的应用程序中完成了底部导航。所以,我想在我的一个片段中创建一个按钮。我怎么做?有视频参考吗?谢谢。

这很容易,也不难,只需在片段布局中放置按钮,然后在片段中创建实例后,为特定按钮(如bellow)放置侦听器

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/mBtnPresent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>



@SuppressLint("ValidFragment")
public class FragmentTest extends Fragment {


    private View view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_test, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        AppCompatButton mBtnPresent=view.findViewById(R.id.mBtnPresent);
        mBtnPresent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //perform action what you want on button click
            }
        });

    }
}

嗨,首先,你的问题标题或描述太不一样了,还有一件事要实现你想实现的,因为你需要掌握安卓的核心知识,这比直接跳转更好。我很抱歉我的标题和描述不相关,因为我不能提交我最初发布的标题。实际上,我的主要任务是,稍后我想使用REST从db中获取一些数据。但是,我需要创建一个可以在片段first Refer图像中单击的按钮。例如,单击“显示”将查看数据。那么,如何在片段中执行按钮呢?现在,我想知道是否可以在片段中执行REST连接?我想从数据库中提取一些数据到那个片段中。在此之前,我尝试从mysql中提取数据,它是有效的。但这一次,我想让我的数据库私有化。因此,我需要使用REST方法。那怎么可能呢?