Android EditContactActivity contains the functionality when + button is pressed new field is added to listview and - button delete that extra field. I need this exact functionality, but I could not find it in Android source code.
How to extract this particular functionality? And if someone can tell me how to understand android source code.
If i remember correctly it's not a ListView at all actually, more like:
<LinearLayout>
<ScrollView>
<LinearLayout>
All the editors go here
</LinearLayout>
</ScrollView>
<LinearLayout>
Buttons and stuff goes here
</LinearLayout>
</LinearLayout>
Basically they're adding and removing items in a LinearLayout at the right position.
If you want to look into the specifics a (complete?) mirror of the Android repo is up at github - the contacts app, for instance, is here: https://github.com/android/platform_packages_apps_contacts
Related
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.
My physical phone runs Android 2.3.3., so I'm developing with a minimum SDK of 10. According to the project creation wizard in Eclipse, that's apparently just one short of being able to choose a Navigation Type besides None.
I want my new app to be scrollable -- how do I do this? For example, can I put my content inside a scrollable element inside the layout parent element?
Just use a ScrollView as parent of your layout.
<ScrollView>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
<LinearLayout>
// your Layout
</LinearLayout>
</ScrollView>
Sounds like you need a ScrollView. And it works for API level 10 too ...
I would like to know if this kind of layout is supported under Android and what is its name.
The description:
the application is revealed by default in a main view and a menu will appear when making a "swipe gesture" from the margins to the center of the screen; usually this layout has to offer some kind of callback or manage to stop the underlaying activity for the application so the user can use the menu without interfering with what he is doing with the application itself.
Thanks.
If you are looking for a sliding layout, here is an example:
you can call it with:
<com.slidingmenu.lib.SlidingMenu
xmlns:sliding="http://schemas.android.com/apk/res-auto"
android:id="#+id/slidingmenulayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
sliding:viewAbove="#layout/YOUR_ABOVE_VIEW"
sliding:viewBehind="#layout/YOUR_BEHIND_BEHIND"
sliding:touchModeAbove="margin|fullscreen"
sliding:touchModeBehind="margin|fullscreen"
sliding:behindOffset="#dimen/YOUR_OFFSET"
sliding:behindWidth="#dimen/YOUR_WIDTH"
sliding:behindScrollScale="#dimen/YOUR_SCALE"
sliding:shadowDrawable="#drawable/YOUR_SHADOW"
sliding:shadowWidth="#dimen/YOUR_SHADOW_WIDTH" />
There is no built in function like that, so you have to use third party libraries
There is no built in functionality for this behavior. You'll need to make it yourself.
I am new to Android development, and have tried researching my question but can not find a suitable answer.
What I am trying to do is create a list of items, like the numbers 0-9 for example, and display that as a list that the user can scroll up or down to select the desired number, starting at 0.
The best example that I can think of is the HTC Sense timer, linked below (can not post pictures as a new user):
Sense Timer:
What I currently have is a Spinner, but that's not exactly what I want. I want the user to simply swipe up/down to make their selection, not press a button to bring up a drop-down list to make their selection.
Is there a simple way to do this that I am missing, or is it a fairly complicated thing to do? I have not been able to find an example on my own.
Thanks
This is simply known as Wheel View in android. I am not much aware of its implementation, but here is a very good demo. Take a look at it.
http://android-devblog.blogspot.in/2010/05/wheel-ui-contol.html
This will get you started with it.
Here is another one,
http://android-devblog.blogspot.in/2011/01/android-wheel-update-custom-views-for.html
Try ScrollView, may this will work:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
//Your Components
</RelativeLayout>
</ScrollView>
You need to use a listview and an adapter for this. Its a very simple way to implement the vertical scrolling list of items. Please refer the code from the following link:
http://developer.android.com/resources/tutorials/views/hello-listview.html
How to add a header to an existing android activity? All the examples that I found with a search engine are showing how to add a header to the list view.
I don't know what you are looking for..might be this answer is useful to you.
You have to add a view the xml that you're using for your layout. So for example, say your Activity is using a linear layout. You'd do:
<LinearLayout android:orientation="vertical" ....>
<LinearLayout....>
<!---- Header Stuff Goes Here ---->
</LinearLayout>
<!--- Rest of the layout for your activity goes here ---->
</LinearLayout>
What you are looking for is a ActionBar, it is included on 3.0 api but if you want to use with backward compatibility you can use different libraries, my preferit is GreenDroid you can also see an example downloading the GreenDroid Catalog App from Market.
I hope this helped you :)