osmdroid xml file - android

I've made an API that uses the osmdroid jar file and it is fixed on the center of London. The program works fine and you can navigate on the map but I still get this error in the main.xml file :
"org.osmdroid.views.MapView failed to instantiate"
Is there something I should do? Thank you.
<?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">
<org.osmdroid.views.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/mapview">
</org.osmdroid.views.MapView>
</LinearLayout>

Maybe you've already found the answer yourself, but you don't have to be worry about it. I also have this in my project when I use a map view from osmdroid, even with google maps and it works fine. As you can see in my screenshot:
It's not needed to add " xmlns:android="http://schemas.android.com/apk/res/android" " in your org.osmdroid.views.Mapview tag. The only place where you have to add the xmlns is in your root layout item. In this case, as it it's done well, in your LinearLayout. See my code below of an example of my osmdroid tag and it's working fine:
<org.osmdroid.views.MapView
android:id="#+id/osmMV"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="20dip"
android:layout_weight="1"
android:clickable="true" />
Have a nice development!
Kr

Related

Moving android adView code from Library layout file to the advert based app layout

I have an android app which is marked as library and two more apps (trial version and full) which are essentially using the library and only have a package name and little bit of code in there like one has to have adverts and others don't etc.
So all (99.9%) of the code lives in library whichever app is used.
The following is the main Layout xml file of the LIBRARY APPLICATION. The adView element is also present in this file and I would like only the adview Element to be somehow in the trial app's layout without duplicating the entire layout of the library.Trial app has no layout right now it just has the libray as dependency.
How can I achieve moving the adView element code from the layout below to the relevant app who right now has no layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:orientation="vertical" >
.... more code here
</LinearLayout>
<LinearLayout
android:id="#+id/info_window"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:orientation="horizontal">
...more code here
</LinearLayout>
</LinearLayout>
Edit: Just to add little bit more detail the app has minApi 9 and does not use support library etc
I wouldn't remove the AdView from your library XML. I would instead use code in your apps to only load and show the banner ads in the relevant app.

No resource identifier found for attribute 'indicator_gravity' in package

I was trying to porting the Tree-View-List-Android into my project recently. I have created a project called com.dotnetideas.treeview and added everything in. I can run the demo without any issue. But when I use it in another project, I kept getting “No resource identifier found for attribute 'indicator_gravity' in package com.dotnetideas.treeview” in main_demo.xml.
Here is the xml looks like.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:treeView="http://schemas.android.com/apk/res/com.dotnetideas.treeview"
android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ListView android:layout_width="0dip" android:layout_height="0dip" android:scrollbars="vertical"
android:visibility="gone"> <!-- Just to test some attributes in IDE -->
</ListView>
<pl.polidea.treeview.TreeViewList android:id="#+id/mainTreeView" android:layout_width="fill_parent"
android:layout_height="fill_parent" treeView:indicator_gravity="right|center_vertical"
android:scrollbars="vertical" android:smoothScrollbar="true"/>
Although I followed the old code to changed the xml namespace from
xmlns:treeView=http://schemas.android.com/apk/res/pl.polidea.treeview
to
xmlns:treeView=http://schemas.android.com/apk/res/com.dotnetideas.treeview.
It doesn’t seem like valid xml namespace.
It turned out that the namespace needs to be
xmlns:treeView="http://schemas.android.com/apk/res-auto"
if we reference as a library project.
This answer from stackoverflow too didnt help.

Graphical layout in eclipse doesn't work with inserted fragment

I'm using Eclipse ADT and I'm having a problem with a layout file. I can open it the internal xml editor, but when I open the Graphical Layout tool, it doesn't show anything, as if there was no xml file there.
This is the xml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hermes.view.activities.SubTaskActivity" >
<fragment
android:id="#+id/map_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="35"
android:layout_marginBottom="15dp"
android:name="com.hermes.view.fragments.MiniMapFragment"/>
<ListView
android:id="#+id/list_subtaks"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="60" />
</LinearLayout>
Note: I wanted to show a screenshot of the Graphical Layout tool, but StackOverflow doesn't allow it for reputation stuff :/
Is this an eclipse bug or am I doing something from with the xml file. I must also say that this only happens if I put a fragment in the xml file; if I remove the fragment tag, the problem disappear, but I need to see the design with the fragment in it !.
Thanks for the help

Android Application:Error "Found text"

I have been following a book on Android "Beginning Android Application". I have been trying to figure out an application which shows images in a view. But unfortunately I could not run the application because of the following errors:
[2012-04-24 19:37:33 - Gallery] F:\eclipse workspace\Gallery\res\values
\attrs.xml:2:error: Found text "
[2012-04-24 19:37:33 - Gallery] ​​​​ " where item tag is expected
For convenience I am giving here the codes.
main.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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Bilai"
/>
<Gallery
android:id="#+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/image1"
android:layout_width="320px"
android:layout_height="250px"
android:scaleType="fitXY"
/>
</LinearLayout>
This application requires another xml file. It is named as attrs.xml under res/values.
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
​<declare-styleable name="Gallery1" >
​​​​<attr name="android:galleryItemBackground" />
​​​</declare-styleable>
</resources>
I think the problem lies within attrs.xml, but I dont know whats going on. And because of this the R.styleable also doesnt work either. Please help. Thanks in advance
I think you have some characters before each line in your attrs.xml due to a copy/past method.
Can you try to reformat your code by placing your text cursor at the beginning of each line and delete to return to previous line ?

Android - Layout error

I'm trying to create a button. I've done something like this before, but now I got an error and I' can't find out what is it. I think i've got the problem in the xml file, but can't find it :S
So there is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageButton
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="115dp"
android:layout_marginTop="80dp"
android:src="#drawable/login_button" />
</RelativeLayout>
I'm trying to implemet some kind of facebook login. I'm using the easyfacebook sdk. So here is the java code where i trying to implement the login button:
http://pastebin.com/brHmJKs1
The messages i get is the following:
W/webcore(29941): Can't get the viewWidth after the first layout
E/SkLayout_wtle(29941): layout error:106 width:0 ellipsizedWidth:0
W/InputManagerService(1171): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#405c4e68
First close your first LinearLayout in last line.Secondly remove RelativeLayout, that is of no use and then try i hope you will get success.

Categories

Resources