Created
October 9, 2018 03:22
-
-
Save izzuddin91/a7dd9875cdf0396464f1fa7f9bafb60a to your computer and use it in GitHub Desktop.
Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mImageView = (ImageView) findViewById(R.id.imageView1); | |
mImageView.setImageResource(R.drawable.camera); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//for tableview function | |
TableLayout table = (TableLayout)findViewById(R.id.displayInputTable); | |
TableRow row = new TableRow(this); | |
row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); | |
TableRow row2 = new TableRow(this); | |
row2.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); | |
TextView tv = new TextView(this); | |
tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); | |
tv.setText("New Entry"); | |
TextView tv2 = new TextView(this); | |
tv2.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); | |
tv2.setText("New Entry Test 2"); | |
for (String s : title){ | |
System.out.println(s); | |
TableRow row3 = new TableRow(this); | |
row3.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); | |
TextView tv3 = new TextView(this); | |
tv3.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); | |
tv3.setText(s); | |
row3.addView(tv3); | |
table.addView(row3); | |
} | |
row.addView(tv); | |
// row.addView(tv2); | |
row2.addView(tv2); | |
table.addView(row); | |
table.addView(row2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
radioGroup1 = (RadioGroup) findViewById(R.id.radioGroup1); | |
btnDisplay = (Button) findViewById(R.id.button2); | |
btnDisplay.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
int selectedId=radioGroup1.getCheckedRadioButtonId(); | |
radioButton=(RadioButton)findViewById(selectedId); | |
System.out.println(radioButton.getId()); | |
// Toast toast = Toast.makeText(getApplicationContext(), | |
// "This is a message displayed in a Toast", | |
// Toast.LENGTH_SHORT); | |
// | |
// toast.show(); | |
Toast.makeText(MainActivity.this,radioButton.getText(),Toast.LENGTH_SHORT).show(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Switch toggle = (Switch) findViewById(R.id.switch1); | |
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |
if (isChecked) { | |
// The toggle is enabled | |
System.out.println("switch on"); | |
} else { | |
// The toggle is disabled | |
System.out.println("switch off"); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment