To Remember…
android:gravitysets the gravity of the content of the View it’s used on.android:layout_gravitysets the gravity of the View or Layout relative to its parent.
programming ideas…
android:gravity sets the gravity of the content of the View it’s used on.android:layout_gravity sets the gravity of the View or Layout relative to its parent.Maybe your problem is something like this: you want to use some elements that are described in other xml then your main content view.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maingui);
...............
For instance, if you want to add a WebView in an existing activity and that webview is a self alone xml separated from your maingui.xml, in your java code all you need to do is this:
LayoutInflater layoutInflater = (LayoutInflater) this. getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.webviewlayout, mWebView);
mWebView = (WebView) view.findViewById(R.id.webview);
And from now on you can use mWebView in your logic, think of it as it’s your own in the class you are working on.
Have fun.
Design in Android is very painful for me.
You get this error if in your Gui xml file you “connect” two elements both way, something like saying item A is android:layout_toRightOf=”@+id/itemB” and item B is android:layout_toLeftOf=”@+id/itemA”.
One connection is enough.
I did not found the solution, but I found the answer on StackOverflow and it saved my day/night. I was trying to import a mysql connector jar to use in my android application that needs to connect to a remote database. I constantly got this nicely drawn error:
If you are having fun with Cursor from Android and get this error you might wanna take a second look at the conditions you are passing to the Cursor object:
- check Projection, Selection, Selection Arguments, Order by…
Maybe you are trying to set information that you are not “calling” from projection.
Hope it helps.
If you want to use the SD Card within an Android Emulator, you need to do two things:
1. add the permission in the manifest xml file:
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />
2. Configure your AVD to actually have an sd card. See figure below:
1. Pull data from emulator and save a copy on the computer
C:\Program Files\Android\android-sdk-windows>adb pull data/data/com.sthg.test/databases
pull: building file list…
pull: data/data/com.sthg.test/databases/X.db -> ./X.db
1 file pulled. 0 files skipped.24 KB/s (18432 bytes in 0.731s)
2. Push data from computer to the android emulator
C:\Program Files\Android\android-sdk-windows>adb push X.db data/data/com.sthg.test/databases/212 KB/s (7168 bytes in 0.033s)
Your question: where is my local android emulator database?
What are you using: windows
Before you start: make sure adb recognises your devices. To test this run : adb devices. If you get an empty list, don’t panic. The solution is to run your application.(why can’t it find the devices without starting the emulator beats me. When you want to run an application and choose a virtual device it knows the entire list.)
Hello,
If you get to a point when you get this error(to see it you have to open the DDMS console from Eclipse):
ddms]nulljava.lang.NullPointerException at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)at com.android.ddmlib.Client.sendAndConsume(Client.java:573)at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)at com.android.ddmlib.Client.getJdwpPacket(Client.java:670)at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
then… this can mean that the activity stack of your project is either full or better yet, you forgot to close/exit/finish an activity somewhere.
Look in your code for places where you forgot to call the “finish()” method after this line that is starting another intent. startActivityForResult(myIntent, RESULT_OK); . So you should have this:
startActivityForResult(myIntent, RESULT_OK);
finish();
This took me hours to figure out, the small things just elude our mind(eyes in this case) sometimes, when we look for major mistakes we forget to look at the potential small ones. Debugging is the key either way.
Hope this helps you.
Enjoy.