TableRow TableLayout table row add delete remove removeview addview Android example
TableRow TableLayout table row add delete remove removeview addview get table row index indexOfChild create table row dynamically TextView dynamically Android example
Main.java
main.xml ScrollView, TableLayout, TableRow, TextView Android xml layout example
Main.java
TableLayout table = (TableLayout)findViewById(R.id.table);
TableRow row = (TableRow)findViewById(R.id.row);
// get table row index android.
int nIndex = table.indexOfChild(row);
table.removeView(row); // invisible and height == 0
// add row into same place
table.addView(row, nIndex); // visible
// add row into certain position
table.addView(row, 3); // visible
// create new TableRow dynamically
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
// create own function for append TableRow
private void appendRow(TableLayout table) {
TableRow row = new TableRow(this);
TextView hLabel = new TextView(this);
hLabel.setText("Some text");
hLabel.setPadding(3, 3, 3, 3);
TextView hNextLabel = new TextView(this);
hNextLabel.setText("Next text");
hNextLabel.setPadding(3, 3, 3, 3);
hNextLabel.setGravity(Gravity.RIGHT | Gravity.TOP);
row.addView(hLabel, new TableRow.LayoutParams(1));
row.addView(hNextLabel, new TableRow.LayoutParams());
table.addView(row, new TableLayout.LayoutParams());
}
main.xml ScrollView, TableLayout, TableRow, TextView Android xml layout example
<ScrollView xmlns:android="//schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row index 0"/>
</TableRow>
<TableRow android:id="@+id/row">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row index 1"/>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row index 2"/>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row index 3"/>
</TableRow>
</TableLayout>
</ScrollView>
396LW NO topic_id
AD
Další témata ....(Topics)
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
public class SoundManager
{
private SoundPool soundPool;
private int[] sm;
Context context;
public SoundManager(Context context) {
this.context = context;
soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
sm = new int[2];
// fill your sounds
sm[0] = soundPool.load(context, R.raw.my_sound1, 1);
sm[1] = soundPool.load(context, R.raw.my_sound2, 1);
}
public final void playSound(int sound) {
AudioManager mgr = (AudioManager)context.getSystemService(
Context.AUDIO_SERVICE);
float streamVolumeCurrent =
mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = streamVolumeCurrent / streamVolumeMax;
soundPool.play(sm[sound], volume, volume, 1, 0, 1f);
}
public final void cleanUpIfEnd() {
sm = null;
context = null;
soundPool.release();
soundPool = null;
}
}
First cteate big icon 512x512 px formtat .PGN in graphics editor as Photoshop, Gimp, Piant.NET and save image.
If you create new project via Eclipse and choice your 512x512 image for ic_launcher.
Eclipse will make all icons from this image for new application very well.
If you create new project via Eclipse and choice your 512x512 image for ic_launcher.
Eclipse will make all icons from this image for new application very well.
If you using Context as parameter of function try this solution:
public class MyActivity extends Activity {
// bla bla bla .......
//error
myFc( getapplicationcontext());
// OK
myFc(MyActivity.this);
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Error parsing the sdk.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Failed to create C:\Program Files\android\sdk\add-ons.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Unable to parse SDK content.
You have to create add-ons folder as admin of PC
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Failed to create C:\Program Files\android\sdk\add-ons.
[2013-07-06 16:10:29 - SDK Manager] [SDK Manager] Error: Unable to parse SDK content.
You have to create add-ons folder as admin of PC
Click to Android version combobox - drop down menu and select your version, which just using (have instaled). For example: You updated ADT by SDK manager, but forget to update Android version. You can use lower version from drop down menu, which using your project, or do update of Android by SDK manager.
Editace: 2011-09-18 08:32:50
Počet článků v kategorii: 396
Url:tablerow-tablelayout-table-row-add-delete-remove-removeview-addview-android-example