Android - some basic control & resource operations
- get control by resource id
(Button)findViewById(R.id.btnMtFaberLine)
dropdownDirection = (Spinner)findViewById(R.id.spinnerWelcome);
String[] items = new String[]{"Entry","Exit"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items);
dropdownDirection.setAdapter(adapter);
- set textview text and bold
TextView textViewUserName = (TextView)findViewById(R.id.usernameTV)
textViewUserName.setTypeface(null, Typeface.BOLD)
textViewUserName.setText("User: " + username)
ImageView img1 = (ImageView) findViewById(R.id.imageView1)
img1.setImageDrawable(null)
img1.setImageResource(R.drawable.check)
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), R.raw.wrong);
mp.start();
SimpleDateFormat dtFormater = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss",
Locale.ENGLISH);
dtFormater.format(new Date());