有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Android Studio,使用PHP数据库文件中的GET用4个随机元素填充列表视图

我正在做一个项目,我正在创建一个(非常)简单的锻炼生成器应用程序,让你登录,然后提示你选择推、拉或腿部锻炼。这将带您进入另一个屏幕,在那里它将生成一个例程,该例程由4个训练组成,这些训练是使用GET函数从PHP文件中的数组中随机选择的

所以我的问题是: 如何创建列表,然后用数组元素填充列表? 我只是有点迷路了谢谢

以下是我的拉力训练片段,如果有帮助的话

package com.example.workoutapp;

import 安卓.os.Bundle;

import 安卓x.fragment.app.Fragment;
import 安卓x.navigation.Navigation;

import 安卓.view.LayoutInflater;
import 安卓.view.View;
import 安卓.view.ViewGroup;
import 安卓.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;
    }
}

共 (0) 个答案