Android RadioGroup alignment like TableLayout
xml example source code with image.
<TableLayout android:layout_width="match_parent" android:id="@+id/idTableInRadioGroup" android:layout_height="wrap_content">
<TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<RadioGroup android:id="@+id/idRadio_group_1_column"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<RadioButton android:id="@+id/idRadio_1"
android:text="@string/textLabel_1"/>
<RadioButton android:id="@+id/idRadio_2"
android:text="@string/textLabel_2"/>
<RadioButton android:id="@+id/idRadio_3"
android:text="@string/textLabel_3"/>
</RadioGroup>
<RadioGroup android:id="@+id/idRadio_group_2_column"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<RadioButton android:id="@+id/idRadio_4"
android:text="@string/textLabel_4"/>
<RadioButton android:id="@+id/idRadio_5"
android:text="@string/textLabel_5"/>
<RadioButton android:id="@+id/idRadio_6"
android:text="@string/textLabel_6"/>
</RadioGroup>
</TableRow>
</TableLayout>
396LW NO topic_id
AD
Další témata ....(Topics)
If you create a button or view programmatically with OnClickListener you can set a tag key before button in parent layout is added.
And get correct button by this tag getTag() instead getId() in OnClickListener etc.
And get correct button by this tag getTag() instead getId() in OnClickListener etc.
Button button = new Button(getApplicationContext());
int idOfButton = button.getId(); // return -1
button.setTag("my_button");
String sTag = (String) button.getTag(); // return "my_button"
Google Android button example source code for developers.
// get handle
Button myButton;
myButton = (Button)findViewById(R.id.idMyButton);
//set focus
myButton.requestFocus();
// set background image
myButton.setBackgroundResource(R.drawable.backImage);
// or
myButton.setBackgroundDrawable(getResources().getDrawable( R.drawable.someImage));
// set visibility
myButton.setVisibility(View.INVISIBLE); // VISIBLE
///////// SET LISTENER
Button myButton =(Button)findViewById(R.id.button1);
myButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "AHOJ",
Toast.LENGTH_LONG).show();
}
});
// or set onClickListener
myButton.setOnClickListener(myListener);
//end onCreate .....
private OnClickListener myListener = new OnClickListener() {
public void onClick(View v) {
}
}
Get assets folder files to array of strings.
Its show files in assets folder and sub folders:
Its show files in assets folder and sub folders:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final AssetManager assetManager = getAssets();
try {
// for assets folder add empty string
String[] filelist = assetManager.list("");
// for assets/subFolderInAssets add only subfolder name
String[] filelistInSubfolder = assetManager.list("subFolderInAssets");
if (filelist == null) {
// dir does not exist or is not a directory
} else {
for (int i=0; i<filelist.length; i++) {
// Get filename of file or directory
String filename = filelist[i];
}
}
// if(filelistInSubfolder == null) ............
} catch (IOException e) {
e.printStackTrace();
}
}
android:autoLink="all"
<!-- text1 automatically linkifies things like URLs and phone numbers. -->
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoLink="all"
android:text="@string/link_text_auto"
/>
Change the title associated with this activity. If this is a top-level activity, the title for its window will change. If it is an embedded activity, the parent can do whatever it wants with it.
String sTitle = "My new title";
setTitle(sTitle);
Editace: 2011-10-14 20:03:29
Počet článků v kategorii: 396
Url:android-radiogroup-alignment-like-tablelayout