daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 14th, 2018 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MainActivity extends AppCompatActivity
  2.     implements NavigationView.OnNavigationItemSelectedListener,  View.OnClickListener {
  3.  
  4.  
  5. Spinner spinner;
  6. EditText searchFor;
  7. Button SearchButton;
  8. String[] itemsToChoose;
  9.  
  10.  
  11.  
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14.     super.onCreate(savedInstanceState);
  15.     setContentView(R.layout.activity_main);
  16.     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  17.     setSupportActionBar(toolbar);
  18.  
  19.     spinner = (Spinner) findViewById(R.id.spinner);
  20.  
  21.     spinner = (Spinner)findViewById(R.id.spinner);
  22.     ArrayAdapter<String>adapter = new ArrayAdapter<String>(MainActivity.this,
  23.             android.R.layout.simple_spinner_item,itemsToChoose);
  24.  
  25.     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  26.     spinner.setAdapter(adapter);
  27.     spinner.setOnItemSelectedListener(this); //Already got an error here
  28.  
  29.     searchFor = (EditText) findViewById(R.id.input_search);
  30.     SearchButton = (Button) findViewById(R.id.search_button);
  31.     SearchButton.setOnClickListener(this);
  32.  
  33.  
  34.  
  35.     Intent intent = new Intent(this,MyIntentService.class);
  36.     startService(intent);
  37.  
  38.     Intent intentLogin = new Intent(MainActivity.this, LoginActivityU.class);
  39.     startActivityForResult(intentLogin, 0);
  40.     firstLogin = false;
  41.     sp=getSharedPreferences("JsonData", 0);
  42.     check = sp.getString("trompim", null);
  43.  
  44.  
  45.  
  46.     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  47.     ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
  48.             this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  49.     drawer.addDrawerListener(toggle);
  50.     toggle.syncState();
  51.  
  52.     NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  53.     navigationView.setNavigationItemSelectedListener(this);
  54. }
  55.  
  56.  
  57.  
  58. public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
  59.  
  60.  
  61.  
  62.     }
  63. }
  64.    
  65. List<String> timeSlots = new ArrayList<String>();
  66. ArrayAdapter<String> adp;
  67. Spinner spinnerTime;
  68.    
  69. if (hour >=9 && hour <11){
  70.         timeSlots.add("XYZ");
  71.     }
  72.  
  73.     else if (hour >= 11 && hour < 13){
  74.         Log.d(TAG ,"Condition 1");
  75.            timeSlots.add("YZa");
  76.            timeSlots.add("XZa");
  77.     }
  78.     else if ( hour >= 13 && hour <15){
  79.         Log.d(TAG ,"Condition 2");
  80.         timeSlots.add("YZa");
  81.         timeSlots.add("XZa");
  82.         timeSlots.add("YZaZ");
  83.     }
  84.  
  85.  
  86. adp = new ArrayAdapter<String>
  87.             (this,android.R.layout.simple_dropdown_item_1line, timeSlots);
  88. spinnerTime.setAdapter(adp);
RAW Paste Data
Top