Learn Android for Free,issues for developers, mobengineers website provide complete solutions for developers issues posts.It also provides online training for android development

Monday, June 24, 2013

Android Jellybean setError fix

public class EditTextErrorJellyBean extends EditText {
    public EditTextErrorFixed(Context context) {
        super(context);
    }

    public EditTextErrorJellyBean(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public EditTextErrorJellyBean(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onKeyPreIme(int keyCode, KeyEvent event) {
        if (TextUtils.isEmpty(getText().toString())
                && keyCode == KeyEvent.KEYCODE_DEL)
            return true;
        else
            return super.onKeyPreIme(keyCode, event);
    }

    private Drawable lastErrorIcon = null;

    @Override
    protected void onFocusChanged(boolean focused, int direction,
            Rect previouslyFocusedRect) {
        super.onFocusChanged(focused, direction, previouslyFocusedRect);
        showErrorIconHax(lastErrorIcon);
    }

    @Override
    public void setError(CharSequence error, Drawable icon) {
        super.setError(error, icon);
        lastErrorIcon = icon;

        if (error != null) {
            showErrorIconHax(icon);
        }
    }

    private void showErrorIconHax(Drawable icon) {
        if (icon == null)
            return;

        if (android.os.Build.VERSION.SDK_INT != Build.VERSION_CODES.JELLY_BEAN
                && android.os.Build.VERSION.SDK_INT != Build.VERSION_CODES.JELLY_BEAN_MR1)
            return;

              Class<?> textview = Class.forName("android.widget.TextView");
            Field tEditor = textview.getDeclaredField("mEditor");
            tEditor.setAccessible(true);
            Class<?> editor = Class.forName("android.widget.Editor");
            Method privateShowError = editor.getDeclaredMethod("setErrorIcon",
                    Drawable.class);
            privateShowError.setAccessible(true);
            privateShowError.invoke(tEditor.get(this), icon);
        }
}

Monday, June 10, 2013

Regular Expression Meta Characters

 

Regular Expression                   Description

\d                                                Any digits    [0-9]

 .                                                  Match Any character except new line

^                                                  Match the beginning of line

\                                                  escape next meta character

$                                                  Match the end of line

 |                                                    Alteration      ('0r' statement)

()                                                  Grouping

[]                                                  Custom character class

\d                                                Any digits    [0-9]


\D                                                Any non digit      [^0-9]


\s                                                 Any white space character    [\t\n\x0B\f\r]


\S                                                Any non white space charater


\w                                                Any word character


\W                                               Any non word character


Sunday, June 9, 2013

java.lang.IllegalArgumentException: Cannot draw recycled bitmaps

06-10 00:36:34.374: E/AndroidRuntime(2394): java.lang.IllegalArgumentException: Cannot draw recycled bitmaps
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:789)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.GLES20RecordingCanvas.drawBitmap(GLES20RecordingCanvas.java:118)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.widget.ImageView.onDraw(ImageView.java:967)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at com.pensio.papaya.views.PapayaCircularImageView.onDraw(PapayaCircularImageView.java:47)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13707)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12645)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13423)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12643)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13423)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.widget.AbsListView.dispatchDraw(AbsListView.java:2327)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13710)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.widget.AbsListView.draw(AbsListView.java:3653)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12645)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13423)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12643)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13423)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12643)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13423)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12643)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13423)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.draw(View.java:13710)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.widget.FrameLayout.draw(FrameLayout.java:467)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2211)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12645)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.View.getDisplayList(View.java:12689)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1198)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewRootImpl.draw(ViewRootImpl.java:2173)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.Choreographer.doFrame(Choreographer.java:532)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.os.Handler.handleCallback(Handler.java:725)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.os.Looper.loop(Looper.java:137)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at android.app.ActivityThread.main(ActivityThread.java:5039)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at java.lang.reflect.Method.invokeNative(Native Method)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at java.lang.reflect.Method.invoke(Method.java:511)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-10 00:36:34.374: E/AndroidRuntime(2394):     at dalvik.system.NativeStart.main(Native Method)

Wednesday, June 5, 2013

Custom Dialog Android

package com.mobengineers;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class DashboardActivity extends Activity {
    private static final int DIALOG_CUSTOM_ANIMATION = 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void onButtonDownUpActivityClick(View view) {
        startActivity(new Intent(this, DownUpActivity.class));
    }

    public void onButtonDialogClick(View view) {
        showDialog(DIALOG_CUSTOM_ANIMATION);
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DIALOG_CUSTOM_ANIMATION:
            CustomAlertDialog dialog = new CustomAlertDialog(this);
            dialog.setTitle("Swich on Location providers for better !");
            dialog.setCancelable(true);
            dialog.setMessage("How this dialog....  just for fun)");
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setButton("Settings", new DialogInterface.OnClickListener() {
               
                @Override
                public void onClick(DialogInterface dialog, int which) {
                
                    dialog.dismiss();// TODO Auto-generated method stub
                   
                }
            });

            WindowManager.LayoutParams wmlp = dialog.getWindow()
                    .getAttributes();

            wmlp.gravity = Gravity.TOP;

            dialog.show();
            return dialog;
        }
        return super.onCreateDialog(id);
    }
}

06-06 00:10:15.857: E/AndroidRuntime(2704): java.lang.RuntimeException: Unable to start activity

06-06 00:10:15.857: E/AndroidRuntime(2704): FATAL EXCEPTION: main
06-06 00:10:15.857: E/AndroidRuntime(2704): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.goingkilo.textlayout/com.goingkilo.textlayout.app.FlowText}: java.lang.NullPointerException
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.os.Looper.loop(Looper.java:137)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.ActivityThread.main(ActivityThread.java:5039)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at java.lang.reflect.Method.invokeNative(Native Method)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at java.lang.reflect.Method.invoke(Method.java:511)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at dalvik.system.NativeStart.main(Native Method)
06-06 00:10:15.857: E/AndroidRuntime(2704): Caused by: java.lang.NullPointerException
06-06 00:10:15.857: E/AndroidRuntime(2704):     at com.goingkilo.textlayout.data.Image.<init>(Image.java:25)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at com.goingkilo.textlayout.data.Block.addImage(Block.java:27)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at com.goingkilo.textlayout.app.DataFillerUp.fillDoc(DataFillerUp.java:106)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at com.goingkilo.textlayout.app.FlowText.onCreate(FlowText.java:16)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.Activity.performCreate(Activity.java:5104)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-06 00:10:15.857: E/AndroidRuntime(2704):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-06 00:10:15.857: E/AndroidRuntime(2704):     ... 11 more

20% off

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

NDTV Gadgets360

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts