Я новичок в программировании Android. Я создал переработчик, и он отображает элементы из базы данных MySQL. Но я бы хотел, чтобы эти элементы отображались внутри диалогового окна предупреждения, а не во фрагменте. Я понятия не имею, как это сделать.
вот код, который у меня есть:
public class profileFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private SpotsAdapter adapter;
private RecyclerView recyclerView;
private ArrayList<Spots> spotsList;
private Context context;
private SwipeRefreshLayout swipeLayout;
private int refresh_count =0;
private TextView TVspot;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_profile, container, false);
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
swipeLayout.setOnRefreshListener(this);
context = view.getContext();
return view;
}
@Override
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
spotsList = new ArrayList<Spots>();
recyclerView = view.findViewById(R.id.recy);
LinearLayoutManager lm = new LinearLayoutManager(context);
lm.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(lm);
recyclerView.setHasFixedSize(false);
recyclerView.setAdapter(adapter);
Api api = RetrofitClient.getREtrofit().create(Api.class);
Call<ArrayList<Spots>> call = api.getSpotslList();
call.enqueue(new Callback<ArrayList<Spots>>() {
@Override
public void onResponse(retrofit2.Call<ArrayList<Spots>> call, Response<ArrayList<Spots>> response) {
spotsList = response.body();
Log.e("REsult", (spotsList.get(0)).toString());
adapter = new SpotsAdapter(spotsList, context);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
Log.e("sid", adapter.valueOfSid());
TVspot= view.findViewById(R.id.parkingTV);
TVspot.setText("Your parking spot is:" + adapter.valueOfSid());
}
@Override
public void onFailure(retrofit2.Call<ArrayList<Spots>> call, Throwable t) {
Log.e("FAil", String.valueOf(t.toString()));
}
});
}
@Override
public void onRefresh() {
swipeLayout.setRefreshing(false);
Api api = RetrofitClient.getREtrofit().create(Api.class);
Call<ArrayList<Spots>> call = api.getSpotslList();
call.enqueue(new Callback<ArrayList<Spots>>() {
@Override
public void onResponse(retrofit2.Call<ArrayList<Spots>> call, Response<ArrayList<Spots>> response) {
spotsList = response.body();
Log.e("REsult", String.valueOf(spotsList.size()));
adapter = new SpotsAdapter(spotsList, context);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
TVspot.setText("Your parking spot is:" + adapter.valueOfSid());
}
@Override
public void onFailure(retrofit2.Call<ArrayList<Spots>> call, Throwable t) {
Log.e("FAil", String.valueOf(t.toString()));
}
});
adapter.notifyDataSetChanged();
Log.e("FAil", String.valueOf(spotsList.size()));
}
}
любая помощь и предложения о том, как поместить элементы переработчика внутри модуля alerttdialog, будут высоко оценены.