Payday Loan Payday Loan

Archive for the ‘Compatibility’ Category

Hi,
I want to show you a method that can help you to show the three dots(Menu button) on Action Bar.
This button is not shown on the ActionBar if the device HAS ALREADY A MENU BUTTON.
To overcome this please call in your onCreate() method the following method:

private void getOverflowMenu() {
 
     try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if(menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
||||| 0 I Like It! |||||

How to cast from View to WebView in Android

I have faced a really idiot problem, and i want to share it with you.
I tried to make a very simple webview activity like below:

 
package com.demoapp;
 
import android.app.Activity;
import android.os.Bundle;
import com.demoapp.R;
import android.webkit.WebView;
public class WebView extends Activity {
 
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.webview);
		Bundle data = getIntent().getExtras();
 
		WebView webview1 = (WebView)findViewById(R.id.webView1);
 
        webview1.getSettings().setJavaScriptEnabled(true); 
        webview1.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
 
        webview1.getSettings().setBuiltInZoomControls(true);
	    webview1.setInitialScale(50);
        webview1.loadUrl(data.getString("webview")); 
 
	}
 
}

This is looking perfect, but the Eclipse dont let you compile this.
You will get error: cannot cast from View to WebView.
You need to observe that the import android.webkit.WebView; cannot be fullfiled.
WHY? Because you have setted the class name same. As you see my class name is WebView.
This generates a conflict, between imported class WebView, and your class called WebView, so just change the name of your class to something like WebView1 and you are done.

||||| 0 I Like It! |||||

Softkeyboard obscure (overlaps) EditText

This is a major problem that i have meet and took me some hours to find the answer, because no one wrote a clear solution, even though is a very simple one.
If your Android virtual keyboard overlaps your editText that is on a lower part of the screen, then you need to modify your AndroidManifest file.
How? Very simple in your activity you need to add:

 android:windowSoftInputMode="adjustPan"

More clearly.
Your declaration of activity looks like this:

     <activity android:name=".Main"
           android:windowSoftInputMode="adjustPan"
</activity>

I hope this helped you.

||||| 0 I Like It! |||||

I have searched a lot through the internet, to find and put together a method to make apps working on all devices.
In fact i have managed to resolve this for only 3 screen sizes: 320×480 at 160dpi…
480×854 or 480×800 at 240 dpi and Galaxy tab resolution 640×1024 360dpi.
For this to work, first you will need to put in the manifest the following code, that will allow supporting
of multiple screens:

After you’ve done this, you will need the following folders created on your res folder.

In drawable-mdpi, you will put the graphics for 320×480 sized devices.
In drawable-hdpi, you will put graphics for 480×854 or 480×800 or 640×1024.
Graphics must be optimized for 640×1024, because for 480×854, you can resize it in the folder layout-normal-hdpi, where you can control the size of the graphics.
Now in layout-normal-mdpi will be main.xml let’s say.
This will be the layout for the 320×480 devices. Here you can customize it as you wish. Nothing that you make here will not happen for other devices.
In layout-normal-hdpi will be same a main.xml
But now this screen is for 480×854 devices.
You can do here your layout as you wish. Even is called main.xml(same as above), all you make here will be displayed only on 480×854 screens.
In layout-large-hdmi you can modify and adapt the layout for the Samsung Galaxy Tab.(640×1024)

I think this is clear and helped you. If you have questions, please register and ask.

||||| 0 I Like It! |||||

Search

Popular

Sponsors