AndroidStudio,使用php数据库文件中的get用4个随机元素填充列表视图

2uluyalo  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(191)

我正在做一个项目,我正在创建一个(非常)简单的锻炼生成器应用程序,让你登录,然后提示你选择推,拉,或腿部锻炼。这将带您进入另一个屏幕,在该屏幕上,它将生成一个例程,该例程由4个训练组成,这些训练是使用get函数从php文件中的数组中随机选择的。
所以我的问题是:如何创建列表,然后用数组元素填充列表?我只是有点迷路了谢谢!
如果这有帮助的话,下面是我的拉力训练片段。

package com.example.workoutapp;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.workoutapp.model.PushWorkoutModel;
import com.example.workoutapp.model.WorkoutFormatRequest;
import com.example.workoutapp.model.WorkoutReps;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link pullWorkoutFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class pullWorkoutFragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public pullWorkoutFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment pullWorkoutFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static pullWorkoutFragment newInstance(String param1, String param2) {
        pullWorkoutFragment fragment = new pullWorkoutFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_pull_workout, container, false);

        view.findViewById(R.id.pullBackButton).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Navigation.findNavController(view).popBackStack();
            }
        });
        return view;
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题