Tag Archives: example

2,677 views

Two boolean as one parameter value in function Java

boolean fc(boolean b) { return b; }// end fc boolean bA = true; boolean bB = true; boolean bC = bA || bB; // true   bA = true; bB = false; bC = bA || bB; // true   … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on Two boolean as one parameter value in function Java
4,770 views

Save Restore Array List Android Example

int[] mArrayOfInt; String[] mArrayOfString; List<String> mList; public void saveState(Bundle map) { map.putIntArray("mArrayOfInt", mArrayOfInt); map.putStringArray("mArrayOfString", mArrayOfString); map.putStringArrayList("mList", mList); }   public void restoreState(Bundle map) { mArrayOfInt= map.getIntArray("mArrayOfInt"); mArrayOfString = map.getStringArray("mArrayOfString"); mList = map.getStringArrayList("mList");   }

Posted in Android Examples Code, Array,List,Collections | Tagged , , | Comments Off on Save Restore Array List Android Example
4,759 views

Not request focus EditText if startup Android

Not request focus EditText if startup Android – hide keyboard if startup. Remove: from EditText Create a LinearLayout and set the: attributes android:focusable=”true” android:focusableInTouchMode=”true” <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:focusable="true" android:focusableInTouchMode="true" android:orientation="vertical" > </LinearLayout>

Posted in Android Examples Code | Tagged , , | Comments Off on Not request focus EditText if startup Android
10,345 views

Spinner Text Size Android Example

Spinner _spin1 = (Spinner) findViewById(R.id.spinLangFirst); ArrayAdapter<String> adapterJazyky = new ArrayAdapter<String>(this, R.layout.spinner_text_layout.xml, {"one","two","etc…."}); adapterJazyky.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); _spin1.setAdapter(adapterJazyky); spinner_text_layout.xml <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinnerText" android:layout_width="fill_parent" android:layout_height="wrap_content"   android:textSize="20sp" />

Posted in Android Examples Code | Tagged , | Comments Off on Spinner Text Size Android Example
4,917 views

Play Sound Android Example

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 … Continue reading

Posted in Android Examples Code | Tagged , | Comments Off on Play Sound Android Example
2,775 views

How get bitmap dimension without loading Android example

Bitmap Width, Height without memory allocation: BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.myimage, options); // now opts.outWidth and opts.outHeight are the dimension of the // bitmap, even though Bitmap is null int imageHeight = options.outHeight; int imageWidth … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , | Comments Off on How get bitmap dimension without loading Android example
3,132 views

How to create icon for Android apps

First cteate big icon 512×512 px formtat .PGN in graphics editor as Photoshop, Gimp, Piant.NET and save image. If you create new project via Eclipse and choice your 512×512 image for ic_launcher. Eclipse will make all icons from this image … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , | Comments Off on How to create icon for Android apps
14,299 views

How to Scroll large image in ImageView Android Example

main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:gravity="top" android:layout_width="fill_parent" android:layout_height="fill_parent" >   <ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="wrap_content" >   <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_width="match_parent" android:layout_height="wrap_content" >     <LinearLayout android:gravity="top" android:layout_width="fill_parent" android:layout_height="wrap_content" >   <ImageView android:id="@+id/imageViewObrazekGeometrie" android:layout_width="360dp" android:layout_height="777dp" android:src="@drawable/geometrie_vzorecky" />   </LinearLayout> </HorizontalScrollView> </ScrollView>   </LinearLayout>

Posted in Android Examples Code, Bitmap, drawing | Tagged , | Comments Off on How to Scroll large image in ImageView Android Example
12,376 views

Resize ImageView Image in View Android Example

How to resize an image in ImageView Android source code. Resize imageview layout and image will resize too: public void resizeImageView(int width, int height) { final ImageView picture1 = (ImageView)findViewById(R.id.imageView1); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height); picture1.setLayoutParams(layoutParams); }

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Resize ImageView Image in View Android Example
3,503 views

Set Custom Font to View Android Example

You have to put your font fonts/samplefont.ttf into assets/fonts folder in your project! // set own custom font from assets TextView txt = (TextView) findViewById(R.id.custom_font); Typeface mFace = Typeface.createFromAsset(getContext().getAssets(), "fonts/samplefont.ttf"); txt.setTypeface(mFace);

Posted in Android Examples Code | Tagged , | Comments Off on Set Custom Font to View Android Example