Tuesday, August 23, 2011

Android Horizontal ScrollView Menu Bar

Android Horizontal Scroll View with custom Layout.

Download Scource Code
we can create custom horizontal menu bar... using horizontal scroll view

layout.xml
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
 
    <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout
        android:id="@+id/horizontalMenu"  android:orientation="horizontal"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        >
            <Button android:text="Button" android:id="@+id/button1"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
         <TextView android:text="1" android:id="@+id/textView1"
    android:layout_width="100dip"
    android:layout_height="wrap_content"></TextView>
  
     <TextView android:text="2" android:id="@+id/textView1"
    android:layout_width="100dip"
    android:layout_height="wrap_content"></TextView>
     <TextView android:text="3" android:id="@+id/textView1"
    android:layout_width="100dip"
    android:layout_height="wrap_content"></TextView>
     <TextView android:text="4" android:id="@+id/textView1"
    android:layout_width="100dip"
    android:layout_height="wrap_content"></TextView>
        </LinearLayout>
    </HorizontalScrollView>
  
  
</LinearLayout>





Thursday, August 18, 2011

android.content.res.Resources$NotFoundException:

Resources NotFoundException

 The below Resources$NotFoundException log results from user error and is easily fixed.

 ERROR/AndroidRuntime(9202): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
08-18 12:32:14.057:
ERROR/AndroidRuntime(9202):   at android.content.res.Resources.getText(Resources.java:201)
08-18 12:32:14.057:
 ERROR/AndroidRuntime(9202):  at android.widget.TextView.setText(TextView.java:2853)

 

I get this error when I am trying to set a View’s text using an integer value like:

 text.setText(SomeInteger) // This is incorrect !

Instead, to set the text of a view using an integer, you need to do:
text.setText(Integer.toString(SomeInteger)) // setText with an int
The problem is that setText(int) is reserved for string resource ids, like:
view.setText(R.string.someStringId) // setText with a string resource id

 

 

Tuesday, August 16, 2011

Get camera capture image path in android

Get camera capture image path in android

calling camera 
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    startActivityForResult(Intent.createChooser(cameraIntent,"Select Picture"), CAMERA_PIC_REQUEST1);




on result activity


 final ContentResolver cr = getContentResolver();    
                   final String[] p1 = new String[] {
                           MediaStore.Images.ImageColumns._ID,
                           MediaStore.Images.ImageColumns.DATE_TAKEN
                   };                   Cursor c1 = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC");     
                   if ( c1.moveToFirst() ) {
                      String uristringpic = "content://media/external/images/media/" +c1.getInt(0);
                      Uri newuri = Uri.parse(uristringpic);
                      Log.i("TAG", "newuri   "+newuri);
                   
                }
                   c1.close();
               
                }
then u can
get Uri path capture image

Thursday, August 11, 2011

Android copy image from gallery folder onto SD Card

Android copy image from gallery folder onto SD Card

You can launch the gallery picker intent with the following:
 intent directly calling gallry folder only
Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI)


//method
 public void imageFromGallery() {
    Intent getImageFromGalleryIntent = 
      new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    startActivityForResult(getImageFromGalleryIntent, SELECT_IMAGE);
}


---------*************----------------
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        switch(requestCode) {
        case SELECT_IMAGE:
            mSelectedImagePath = getPath(data.getData());
            break;
    }
}
public String getPath(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    startManagingCursor(cursor);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}

Android ListView Disable Divider Line and Background Color

Android ListView Disable Divider Line  and Background Color

in android listview if u don't want divider line u have to add this line in listview tag
android:divider="#00000000"
 android:dividerHeight="0dip"

if u don't want background color u have add this line
 android:cacheColorHint="#00000000"

<ListView android:layout_height="fill_parent"
 android:id="@+id/albumListView"
 android:cacheColorHint="#00000000"
 android:divider="#00000000"
 android:dividerHeight="0dip"
  android:layout_width="fill_parent">
  </ListView>

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...