Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Adding TableRow add row with a View TextView dynamically to TableLayout Android sample example


AD MOB

Adding TableRow with a View TextView (EditText Button) programmically dynamically to TableLayout Android sample basic example.
MainClass.java

public class MainClass extends Activity {
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        TableLayout tl = (TableLayout)findViewById(R.id.tableLayout1);
        TableRow row = new TableRow(this);
        TextView tv = new TextView(this);
        tv.setText("This is text");

        tl.addView(row);
        row.addView(tv);

    }
}



main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TableLayout android:layout_width="fill_parent" 
    android:id="@+id/tableLayout1" android:layout_height="wrap_content">
</TableLayout>
</LinearLayout>


397LW NO topic_id




AD

Další témata ....(Topics)


119

Html List tag in Android TextView - Android sample | html-list-tag-in-android-textview-android-sample


Html.fromHtml(String) does not support all HTML tags. For example < ul > and < li > are not supported.
Try this source code as a substitute for HTML List Tags.

String str = 
  "•	Cessnock<br />"
 +"•	Dubbo<br />"
 +"•	Goulburn<br />"
 +"•	Grafton<br />"
 +"•	Lithgow<br />"
 +"•	Liverpool<br />"
 +"•	Newcastle<br />"
;

textview.setText(Html.fromHtml(str));


Result:
• Cessnock
• Dubbo
• Goulburn
• Grafton
• Lithgow
• Liverpool
• Newcastle

Supported tags

bla.com























a
b
big
blockquote
br
cite
dfn
div
em
font
h1-h6
i
img
p
small
strong
sub
sup
tt
u
286

Eclipse - Workspace in use or cannot be created chose a different one | eclipse-workspace-in-use-or-cannot-be-created-chose-a-different-one


Open your workspace folder and subfolder .metadata:
C:\Users\workspace\.metadata\

Delete .lock file
141

Create monochromatic bitmap Android example | create-monochromatic-bitmap-android-example



public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GREEN);
            
            Bitmap b = Bitmap.createBitmap(200, 200, Bitmap.Config.ALPHA_8);
             paint.setColor(Color.BLUE);
            
           Canvas c = new Canvas(b);
           c.drawRect(0, 0, 200, 200, paint);
           
           canvas.drawBitmap(b, 10,10, paint);
		}

	}
}



monochromatic bitmap
144

Compressing a bitmap to JPG format Android example | compressing-a-bitmap-to-jpg-format-android-example


Codec, compress(), CompressFormat, quality, decodeByteArray(), Android example source code with image.

public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static Bitmap codec(Bitmap src, Bitmap.CompressFormat format,
			int quality) {
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		src.compress(format, quality, os);

		byte[] array = os.toByteArray();
		return BitmapFactory.decodeByteArray(array, 0, array.length);
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}
		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();
			
			canvas.drawColor(Color.GRAY);
            
                        //  you need to insert some image flower_blue into res/drawable folder
			Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.flower_blue);
                        // Best of quality is 80 and more, 3 is very low quality of image 
			Bitmap bJPGcompress = codec(b, Bitmap.CompressFormat.JPEG, 3);
                   // get dimension of bitmap getHeight()  getWidth()
		   int h = b.getHeight();
           
           canvas.drawBitmap(b, 10,10, paint);
           canvas.drawBitmap(bJPGcompress, 10,10 + h + 10, paint);
           
		}

	}
}



jpg compression android
280

Android Error: Converting to string: TypedValue{t=0x10/d=0xe a=-1} | android-error-converting-to-string-typedvaluet0x10d0xe-a-1


Converting to string: TypedValue{t=0x10/d=0xe a=-1}



14 // error
"18" // ok




Editace: 2011-09-22 14:17:02
Počet článků v kategorii: 397
Url:adding-tablerow-add-row-with-a-view-textview-dynamically-to-tablelayout-android-sample-example

AD
11 Share
Share
Tweet