I'm trying to use the drag/drop functionality from this fine project: https://github.com/bauerca/drag-sort-listview/
First, I've added the library using the instructions on GitHub.
Second, I'm trying to use the XML declaration. This is my main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.dslv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include layout="#layout/header"/>
<com.mobeta.android.dslv.DragSortListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#D9D9D9"
android:dividerHeight="2dp"
android:listSelector="#drawable/list_selector"
dslv:drag_enabled="true"
dslv:drag_scroll_start="0.33"
dslv:drag_start_mode="onDown"/>
</LinearLayout>
But, Eclipse is throwing this error: No resource identifier found for attribute 'drag_enabled' in package 'com.mobeta.android.dslv'; similarly for 'drag_scroll_start' and 'drag_start_mode'.
I'd like to understand on a more general level what I'm doing wrong here. And if anyone can give me specific help for using this library, I'd appreciate that as well.
Since you are refering the attributes fro your library instead of giving the full path of the library give "res-auto"
please see the change
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include layout="#layout/header"/>
<com.mobeta.android.dslv.DragSortListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#D9D9D9"
android:dividerHeight="2dp"
android:listSelector="#drawable/list_selector"
dslv:drag_enabled="true"
dslv:drag_scroll_start="0.33"
dslv:drag_start_mode="onDown"/>
for reference
Related
I'm trying to get a simple listview without any ticks/checkmarks. How do I get rid of them?? Have tried changing background colour, doesn't make a difference.
Here's my xml file for the list activity layout...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ff868686"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#android:id/list"
android:stackFromBottom="false"
android:transcriptMode="normal"
android:listSelector="#ffee8c00"
/>
</RelativeLayout>
In your CSS
li {list-style-type: none;}
I'am trying to load a spinner to my layout and keep geting this error:
The following classes could not be found:
- Spinner (Change to android.widget.Spinner, Fix Build Path, Edit XML)
heres my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Spinner
android:id="#+id/spn_dates"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="displayDatesToSpiner" />
<ListView
android:id="#+id/LST_bought_products"
android:layout_width="match_parent"
android:layout_height="302dp" >
</ListView>
</LinearLayout>
Thanks
This sometimes happens when you rename the standard AppTheme in your android manifest. It will build and deploy just fine, but the xml design editor won't render it.
This is usually because there's an invalid attribute somewhere.
Remove the onClick and it will work.
When creating a custom element with attributes in Android I need to put the namespace of the application in the layout.
For example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res/org.example.mypackage"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.example.mypackage.MyCustomView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
whatever:my_custom_attribute="Hello, world!" />
</LinearLayout>
Does this also requires that the structure of my project in Eclipse be the same as the name of the Android package as definied in the Manifest - as per the example?
Would this work too:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res/org.mycompany.myproduct"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.example.mypackage.MyCustomView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
whatever:my_custom_attribute="Hello, world!" />
</LinearLayout>
Its the package name of your application that should be reflected. So its correct to use it as you are doing.
For example:
In xmlns:whatever="http://schemas.android.com/apk/res/org.mycompany.myproduct the last part org.mycompany.myproduct should be the same as your package name. And you may change xmlns:whatever to anything like xmlns:theblitz but then make sure you do use theblitz as a prefix for your attributes in the xml.
For more info, read this
i have been trying to create an xml file that integrates a relative layout within the a tabbed layout. Here is my code:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<RelativeLayout
android:id="#+id/simpleMode
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</LinearLayout>
</TabHost>
I am receiving a multitude of errors and i can't seem to find what my problem is:
My errors are Relative Layout must be followed by > or />
and
No recourse found that matches the given name at android:id="#+id/simpleMode
Any help would be appreciated Thank You Very Much!!
Please see you are missing " after android:id="#+id/simpleMode.So your xml file is giving error.Just put it and run
The best way to find these errors easily is to run the XML through an XML validator. The XML validator will tell you exactly whats wrong with your XML.
I generally use W3 Schools XML validator here: http://www.w3schools.com/xml/xml_validator.asp
I tried to include admob to an Android app in Eclipse. But I get an error in the layout.xml. Eclipse tells me that com.admot.android.ads.AdView is an unbound prefix. I have the admob library included in the build path, following the pdf instruction. But it still does not seem to find the AdView class. But why?
Here is the layout producing the error:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/renegrothmann.kalah"
android:layout_width="wrap_content" android:layout_height="wrap_content"
>
<renegrothmann.kalah.GameView
android:id="#+id/gameView" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="2px"
/>
<com.admob.android.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
</LinearLayout>
I had the same error wit this layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/topLayout"
>
<!-- Ad Placeholder -->
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a14df07c16f171a"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
/>
</RelativeLayout>
Then I made it:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/topLayout"
>
<!-- Ad Placeholder -->
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a14df07c16f171a"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
/>
</RelativeLayout>
Notice the second xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" in my RelativeLayout in the second example?
In fact if you remove the android namespace declaration xmlns:android="http://schemas.android.com/apk/res/android" it will start moaning about all the android components too.
Change the following
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/renegrothmann.kalah"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
by
<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/renegrothmann.kalah"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
For me it's working with
<TableLayout
android:id="#+id/resultsuperlotto"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" />
Cheers!
Actually, you do not need to add xmlns:ads to a root element (or a parent element).
You can simply add xmlns:ads property to your AdView element, like:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
...>
</com.google.android.gms.ads.AdView>
Check this page.
Maybe you should replace "myapp" at the bottom with "app" or replace "xmlns:app" at the top with "xmlns:myapp". They should probably be the same.
I cannot provide a real answer, since actually I do not know, why it works now. What I did: I restarted with a fresh project. Sometimes, you simply go one wrong step!
Right Click your project, click Properties, click Android, on the Library panel click Add Button
and add both google-play-services_lib and appcompat_v7 libraries
Apply, Refresh, Clean under the Project.
If this doesn't work try the following:
Change the target line in project.properties as target=android-13
Right click on your project and Click Refresh
Click Clean under Project
Hope this will work.