SHARE
TWEET

Untitled

a guest Feb 21st, 2020 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.scc.bukusakuonline.ui.pengaduan;
  2.  
  3.  
  4. import android.os.Bundle;
  5.  
  6. import androidx.fragment.app.Fragment;
  7.  
  8. import android.view.LayoutInflater;
  9. import android.view.View;
  10. import android.view.ViewGroup;
  11. import android.widget.ArrayAdapter;
  12. import android.widget.Spinner;
  13.  
  14. import com.google.android.material.snackbar.Snackbar;
  15. import com.jaredrummler.materialspinner.MaterialSpinner;
  16. import com.scc.bukusakuonline.R;
  17.  
  18. import java.lang.reflect.Array;
  19. import java.util.ArrayList;
  20.  
  21. /**
  22.  * A simple {@link Fragment} subclass.
  23.  */
  24. public class PengaduanFragment extends Fragment {
  25.  
  26.     private ArrayList<String> dropdownlist = new ArrayList<>();
  27.     private Spinner spinner;
  28.     private ArrayAdapter<String> arrayAdapter = null;
  29.  
  30.  
  31.     public PengaduanFragment() {
  32.         // Required empty public constructor
  33.     }
  34.  
  35.  
  36.     @Override
  37.     public View onCreateView(LayoutInflater inflater, ViewGroup container,
  38.                              Bundle savedInstanceState) {
  39.         // Inflate the layout for this fragment
  40.         View v = inflater.inflate(R.layout.fragment_pengaduan, container, false);
  41.  
  42.         spinner = (Spinner)v.findViewById(R.id.spinner_kategori);
  43.  
  44.         dropdownlist.add(0,"Pilih Kategori");
  45.         dropdownlist.add("Rambut");
  46.         dropdownlist.add("Telat");
  47.         dropdownlist.add("Nakal");
  48.         dropdownlist.add("Minggat");
  49.  
  50.         arrayAdapter= new ArrayAdapter<String>(getContext(),R.layout.spinner_layout,R.id.list_item_textview,dropdownlist);
  51.         spinner.getAdapter(arrayAdapter);
  52.  
  53.         MaterialSpinner spinner = v.findViewById(R.id.spinner_pasal);
  54.         spinner.setItems("ice cream", "jelly beam","android","Lollipop","apa");
  55.         spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
  56.             @Override
  57.             public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
  58.                 Snackbar.make(view, "Clicked"+item, Snackbar.LENGTH_LONG).show();
  59.             }
  60.         });
  61.  
  62.         return v;
  63.     }
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top