how to get phone number from my Contacts on android programing - java

i have EditText and button on my form.
how to do this:
when i press the button i want to open all my Contacts,
and when i pick one - i what that his phone number will be in the EditText
thanks in advance

use this links May be it's useful for you.
http://www.java2s.com/Open-Source/Android/Contact/spelldial/org/ravelin/android/ContactAccessor.java.htm
http://developer.android.com/resources/samples/ContactManager/index.html
http://code.google.com/p/android-business-card/source/browse/trunk/android-business-card/BusinessCard/src/com/example/android/?r=3#android%2Fbusinesscard

In this post you can read contact list.
How to call Android contacts list?
there are some methods...
Then set EditText with contact list content
void setText(CharSequence text, TextView.BufferType type)
Sets the text that this TextView is to display (see setText(CharSequence)) and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
:-)

Related

How can I define an ID for my EditText field programmatically?

I have an Activity in my App that adds more EditText fields to my view when a button is clicked.
Now I want to create a new ID for every created EditText-Field. Then I want to use
editText.setId(createdID);
And then I want to add this editText to an ArrayList (thats why I need the ID!)
editTextList.add((EditText) findViewById(createdID));
Any ideas? Thanks!
You can set it with TextView.setId(int id).
Try to see this question for more details.
Android: View.setID(int id) programmatically - how to avoid ID conflicts?
Rather confusing idea. But if you really need - you can set tags to yours EditTexts

Android Studio - Passing a title and description through ListView

I have created an activity which I need to update with posts made up of a "title" and "description". Earlier a ListView was suggested as an option but I do not know how to add two pieces of text (title and description) to each individual item of the ListView through a String array.
There is a "new post" button on the feed interface that opens a new activity containing 2 TextEdit boxes for adding the title and description.
When "post" is pressed on this second activity I am trying to move the title and description into an array that updates the ListView on the first activity with a new item containing the title and description stated within the TextEdit boxes.
Any help would be greatly greatly appreciated,
Aaron.
The best possible way to this is by using a data base. Android has a built in SQLite data base. You can store in all your data into the data base and query it to get a key/value pair array, which you can pass to your listView adapter class and get the data you need into the list view.
Hope this link helps you out-
androidsolution4u.blogspot.in/2013/09/android-populate-listview-from-sqlite.html?m=1

Android EditText does not show all text

I have a code which retrieves HTML source code of a page. I can retrieve and display the full source code on a TextView without any problem. Then, I want to pass all content of TextView to EditText in order to enable Editing the code. But when I pass source code to EditText, EditText does not show all of the code. The code is broken from random locations. It shows some part of the code. I am totally tilted.
Some details:
TextView is in another activity and EditText is in another activity, I am passing TextView content to EditText with Intents.
Do you have any idea?
Thanks in advance.
BR,
Ali
Try this:
EditText text = new EditText(this);
text.setText(Html.fromHtml(html));
text.setMovementMethod(LinkMovementMethod.getInstance());
All the time, I have counted the number of characters that I am passing to the edittext, it is revealed out that whatever website source code I am previewing the count is 10000. And the solution is so simple:
android:maxLength="100000"
That is it! Now I can view up to 100000 characters.

Android: when spinner item is selected how to prompt for additional details

Trying to make a checklist type app that when you select an element from a spinner you will be prompted for additional information. For instance if you select apple it will ask you how many and give you an editable text box to select.
Should I design the page so that it uses a new intent after each item is selected and creates a new page with the prompting and previous selections in it?
Or is there a better method?
OnItemSelectedListener and AlertDialog is the way.
1.Use OnItemSelectedListener and override the ItemSelected()
2.create and show the AlertDialog with edittext inside the ItemSelected method.
If you are not taking so many inputs from user then you can create a simple AlertDialog for getting those values on every item selected from Spinner or if there are lot of inputs needed then you should call a separate activity for that.

Getting Button in Android Search Dialog

how can I access the button on the left in androids search dialog?
http://developer.android.com/images/search/search-ui.png
In the picture above I want to set an onClickListener onto the books icon.
Thanks in advance
Unfortunately, there's no way to do it. You could get to the layout and its elements if you had necessary ids. But the ids of the elements used by SearchDialog are not public, that's why you don't have access to them.

Categories