For the past hour, I've been looking at how to add support libraries to your build path so that I can learn how to use ViewPager. But for some reason, after I add the jars to my build path and clean the project, nothing new shows up in my palette and if I try to copy and past some XML code for a ViewPager in, it doesn't recognize it in the build path! I really have no idea what's going wrong here. Any advice would be greatly appreciated.
Can you post any screenshot or something? It'll be easier for everyone to help you fix the issue.
Anyway you will need to add android-support-v4.jar to use ViewPager. Usually when you add this jar to libs folder and build path, then you can add code to your xml file just like this (it also didn't show up in my palette):
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.test.MainActivity" />
There's an easy way to check your issue.
Create a new Android application in Eclipse/Android Studio
When it asks you to create a activity or not, choose Tabbed Activity and then choose ViewPager in Navigation Style combo-box
Once the project is successfully compiled, customize it the way you want or compare it to your own project to check if you're missing something. Good luck!
Related
My issue is similar to this but Android Studio doesn't tell me anything about a rendering issue or compiler/build errors(I was able to build fine).
Here is what I am seeing(this is a new project)
And the contents of content_main.xml
After reading on different rendering issue threads, I I've tried rebuilding, cleaning, invalidate caches/restart and even starting a new project to see if the layout preview was working(Still empty)
I also played around with different sdk versions(20,19) to see if the layout preview was working but all I got was this quirky issue that I don't think would cause the layout preview to not work.
Does anyone know what my problem is here? I didn't mess around with my initial Gradle files and remove any support library dependencies. Another solution I had in mind was reinstalling Android Studio but that's last resort.
Just check your sdk valid version like example.
Try putting your TextView element into an empty FrameLayout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/my_groups" />
</FrameLayout>
This code above should be put inside your RelativeLayout. Hope it helps.
I'm new at Android testing and I'm trying to test a custom view in an android library and i'm using Android Studio.
I found here : Android: How to test a custom view? that I should use ActivityUnitTestCase and a mock activity.
I have put my xml layout inside projectname/library/src/androidTest/res/layout and my test activity know my layout R id thanks to this : Configuring res srcDirs for androidTest sourceSet.
My issues is in the layout content.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<eu.custom.customView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
In my case, "http://schemas.android.com/apk/res/android" display in red with an error "URI not registered" and the IDE doe's not recognize my custom view if I add it in this xml.
Is there a way to have this layout working without putting it in production code ?
Thanks
Well, in my Eclipse IDE your code looks correct (there are no red lines) may I suggest you to download the ADT-Bundle again or use Android Studio? I think your IDE is corrupted or something in your settings is wrong. Also check if you have downloaded the up-to-date SDK build tools.
I am starting a new project in android.I have to make it like google maps.For example see the image below
The screen will be like this with 2 views.1st mark with red and other with yellow.
Now what i want is that when user drags view 2 from bottom to top it should be like this
How can i achieve this.Please do help me out as i new to andriod development
Thanks
Checkout AndroidSlidingUpPanel library, probably this is what you want to achieve.
There's a similar implementation in this library. Download the sample app here and see the
SlidingUpGridView
SlidingUpListView
SlidingUpRecyclerView
SlidingUpScrollView
SlidingUpWebView
options.
EDIT
Looks like AndroidSlidingUpPanel is a better solution.
EDIT 2
If you don't want to use that library, I suggest use the codes of that library. It's really not that much work.
Create a new package sliderlib or something in your project
Create two classes named ViewDragHelper.java and SlidingUpPanelLayout.java
Copy the contents of the two named classes here
Download these drawables to your drawable directory of your app
Add these values to your attrs.xml (create one if there isn't one)
And in your XML, use your new widget like this.
your_layout.xml
<your.app.package.sliderlib.SlidingUpPanelLayout>
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp">
<!-- Your views to show in your Sliding Up Panel -->
</your.app.package.sliderlib.SlidingUpPanelLayout>
NOTE : The answer may not be exactly right. But it will be a start.
After adding a new Activity to my project I get following error while compiling the layout
Gradle: Error parsing XML: not well-formed (invalid token)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_password"
android:text="<password>"/>
</LinearLayout>
"http://schemas.android.com/apk/res/android" is marked red and hovering pops following message up
URI is not registered ( Setting | Project Settings | Schemas and DTDs )
My Settings>Project Settings>Schemas and DTDs look like that:
I already found some similar questions around here but nothing helped me to solve this issue. I hope someone has an idea... :)
I was having a similar issue. However, the comments did not assist me in the solution to this issue. This answer from this question actually solved my problem.
Summary:
Go to "File > Project Structure > Modules", click "add" and then click "android" and "apply/ok". That should solve anyone having a similar problem but the comments for this question are not helping you.
For me, the problem occured when I created my own subfolder for old code.
Specifically, Android Studio threw an error for all layout files that weren't in the default folder ../res/drawable/, but instead placed in my own subfolder ../res/drawable/backup.
I got the same error for a long time and none of the answers I found online really helped me, or probably I wasn't looking the right way. At the end what I found out was the way I named the directory. So, I was trying to make the landscape layout for my app and named it layout_land. That kept showing me the URI is not registered error. I just had to change the directory name to layout-land.
Summary: No underscores in directory names!
My issue was creating new resource directory for some animation work. The files were .xml and I chose file type as "xml". I got this problem. Changing the file type to "values" and the problem went away. No idea why, could someone explain this to me? I'm using Android Studio on an iMac.
GO to settings >Language&Framework >Schemas&DTD
here add Uri used in your code.
Some special characters not allowed here.
Directly to assign text then with warning
android:text="value"
#string file from get then avoid warning
android:text="#string/hello"
res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
For me this problem was gone when I have made following changes to my project structure on Android Studio.
file->project structure ->SDK Location -> enable check mark for "Use embedded JDK (recommended).
Hope this will help someone.
First thing is go to the project folder in the Android studio and check for any folders which are created by you. It will show this error if you have created any folder on your own.
I just did an update of my SDK and now eclipse is giving me all sorts of totally unwanted warnings in my xml... for example I have a RelativeLayout that doesn't have an id or a background (it's actually a transparent button) and eclipse is warning me that it's a useless element. Is there a way to turn this idiocy off?
TIA
According to the documentation at http://tools.android.com/recent/ignoringlintwarnings you do this by including the tools xmlns:
xmlns:tools="http://schemas.android.com/tools"
And then adding a tools:ignore annotation in the relevant elements:
<RelativeLayout
tools:ignore="UselessParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:layout_centerInParent="true">
This still works perfectly in 2022.
In New Update of Eclipse ADT Plugins will give you New Tool Which Name is Lint here is one SO Link for this tool and it's advantages .Click Here
Now for Disable xml Warnings that are come from Lint Android Tool ,you need to go
Window-->Preferences-->Android-->Lint Error Checking
in this Dialog you will find all Issue for Xml in android and you can make disable it ,if you want to disable.And Make sure you will not disable usefull lint warning because it's help us to find there are multiple ID assign in xml and lot more..