How to change the Tabs Images in the TabHost

If you wish to use different images for the selected and unselected states, then create ‘selector’ XML files in your drawables folder for each tab, e.g. tab1_selector.xml, tab2_selector.xml which should contain the following, replacing the drawable references to your images for selected and unselected states. i.e. <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:state_selected=”true” android:drawable=”@drawable/tab1_selected_image” /> … Read more

How to use images in Android SQLite that are larger than the limitations of a CursorWindow?

Note This is not recommended as it would still likely be quite inefficient in comparison to storing the path to an image file. The obvious answer is to split the image up into manageable parts (chunks) (say 256k chunks (14 such chunks would hold approx 3.5Mb)) allowing the individual chunks to be assembled when required. … Read more

Convert bitmap array to YUV (YCbCr NV21)

Here is some code that actually works: // untested function byte [] getNV21(int inputWidth, int inputHeight, Bitmap scaled) { int [] argb = new int[inputWidth * inputHeight]; scaled.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight); byte [] yuv = new byte[inputWidth*inputHeight*3/2]; encodeYUV420SP(yuv, argb, inputWidth, inputHeight); scaled.recycle(); return yuv; } void encodeYUV420SP(byte[] yuv420sp, int[] argb, int width, … Read more

Upload an Image from camera or gallery in WebView

After struggling a lot I found a code that works for taking files from galley and camera from 5.0+ devices private ValueCallback<Uri> mUploadMessage; private Uri mCapturedImageURI = null; private ValueCallback<Uri[]> mFilePathCallback; private String mCameraPhotoPath; private static final int INPUT_FILE_REQUEST_CODE = 1; private static final int FILECHOOSER_RESULTCODE = 1; private File createImageFile() throws IOException { // … Read more

How to display a list of images in a ListView in Android?

I’d start with something like this (and if there is something wrong with my code, I’d of course appreciate any comment): public class ItemsList extends ListActivity { private ItemsAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.items_list); this.adapter = new ItemsAdapter(this, R.layout.items_list_item, ItemManager.getLoadedItems()); setListAdapter(this.adapter); } private class ItemsAdapter extends ArrayAdapter<Item> { private Item[] items; … Read more

Save image to sdcard from drawable resource on Android

The process of saving a file (which is image in your case) is described here: save-file-to-sd-card Saving image to sdcard from drawble resource: Say you have an image namely ic_launcher in your drawable. Then get a bitmap object from this image like: Bitmap bm = BitmapFactory.decodeResource( getResources(), R.drawable.ic_launcher); The path to SD Card can be … Read more

How to clear an ImageView in Android?

I used to do it with the dennis.sheppard solution: viewToUse.setImageResource(0); it works but it is not documented so it isn’t really clear if it effects something else in the view (you can check the ImageView code if you like, i didn’t). I think the best solution is: viewToUse.setImageResource(android.R.color.transparent); I like this solution the most cause … Read more

Bitmap recycle with largeHeap enabled

You should probably have a look at Displaying Bitmaps Efficiently which includes several ways to handle large Bitmaps Efficiently, Loading Large Bitmaps Efficiently BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.myimage, options); int imageHeight = options.outHeight; int imageWidth = options.outWidth; This will give you the size of the image before downloading and on … Read more

Reading an image file into bitmap from sdcard, why am I getting a NullPointerException?

The MediaStore API is probably throwing away the alpha channel (i.e. decoding to RGB565). If you have a file path, just use BitmapFactory directly, but tell it to use a format that preserves alpha: BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options); selected_photo.setImageBitmap(bitmap); or http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)