Problems with layout - android

I am trying to create my own Phone Dialer from scratch in Eclipse Android, I did a simple phone layout in the XML with numbers 0-9 and some Buttons/ImageButtons.
Basically I put some Buttons and ImageButtons and I understand that I need call setOnClickListener() on them in the Java code. Something like:
Button no1 = (Button) findViewById(R.id.button1);
no1.setOnClickListener(new View.OnClickListener()
I did an <EditText on top of the numbers (Buttons and ImageButtons) to display the numbers. But nothing come out when I click. I am not sure what I miss out which cause this problem.
I also did a "settings" button in the same XML file, which upon clicking on the button, a toast will pop out which have a couple of clickable icons. I am not too sure on how to do it. I did read some tutorials but mine seems to be not quite right.
hopefully if the above-mentioned points can be rectified, I hope I can try to make the SMS characters to be Unicode, which can limit to lets say 50 characters etc.. but that's still far-fetched for me though. I'll do this in the later part.
I did a Google research but I don't quite get the correct info as its just bits and pieces here and there...
Actually I want to create this customized phone dialer as I intent to install it in my Mum's 2.1 Froyo phone.
Can anyone advise me please? Is there a sample code where I can check what I went wrong?

Have your class implement OnClickListener and make a switch(arg0.getId()) and a case for each number pressed.
Every time you press a number have an EditText receive that number and then when you press the call button have it call the numbers in that EditText.

In that amount of time, the application may still have some flaws in it. But you are on the right track. I would have your class xxx.java extend View.OnClickListener, then you can add your class as the listener for each button, e.g. no1.setOnClickListener(this);. Use a switch statement to figure out the phone number and make the call.

Related

EditText custom background

My question is quite short and simple but I'm unable to find a solution. I wan to make my EditText looks like this form:
So, every time the user input a char (android:inputType="numberDecimal"), it goes to the next box. (Just display the char into next box no need to display the cursor). It would be nice if this could be done using a single EditBox.
I have no other idea than making 5 liniar EditText controls and add TextWatcher to every one of it forcing it to jump (focus) to the next one. But this seems a less elegant solution and more complex.
Has anyone any other ideea?
Why reinvent the wheel everytime. I guess this has exactly what you want.
just checkout here https://github.com/Philio/PinEntryView as you required "Just display the char into next box no need to display the cursor".

Android : Editing values using alert dialog

In my application I currently have an xml layout that is re-used to enter information 6 times (these are turns in a game). This works fine. At the end of the round I present a screen that has a summary of each turn. I want to implement a button beside each turn to "edit" that turn. There are 3 possible things that can be edited. Ideally an alert dialog or something like a "popup" would be idea for this.
Would I be best off to have 3 buttons per "turn" for editing or is there a way to do this with a popup?
Thanks for your input on this matter.
You could list each turn and it's information with a single edit button next to each. When the edit button is pressed, create a new activity (intent) that prompts for all three pieces of data.
You have several options (and probably more I'm not thinking about). If these are in a ListView (or even if not) you could use a ContextMenu. You could have options in here to change the selected item or others. This would show a popup when the user long clicks the item
A PopupMenu can give you a similar effect that can pop up a list of options when the user clicks on a Button. Note that this requires API >= 11
You also could use an AlertDialog, as you mentioned. But just from what little I know about what you are trying to do I'm not sure this is what you would want.
Again, I don't know enough details about what you have or want but I would say that one of the first two options would suit you best. As far as one Button or multiple Buttons, that depends on the layout that will work best for your app, I suppose. You certainly could have one "Edit" Button which uses something like a PopupMenu and allows the user to choose what to edit. I hope this helped a little.

Android - call TextWatcher for highlighted text

So I'm new to Android development and I'm currently figuring out TextWatcher.
What I'm attempting to do is attach my TextWatcher listener to an EditText widget and after the user has put in some text, say "Hello" and he highlights "llo" and types in r, I display the change in a TextView widget. For the above example it will display "llo --> r".
Now from what I've read and tried, since the textchangelistener is called every time the user types in something, my code ended up crashing when I ran it on my phone.
Is there a way to call the listener only when the highlighted text is changed so as to avoid calling it every time I'm just typing something in the EditText widget? I hope my question makes sense, I've tried looking around before posting here but I couldn't find anything.
Not looking for code, just some pointers so I can figure out how to do this.
Thanks!
Your best bet would be to use a OnEditorActionListener instead of a textwatcher which I didnt know existed until now. It gets called when there is a change to a textview, and since edit text is a textview than it will work perfectly.
Heres some info on the listener
Btw welcome to the android platform, I think you'll find that it is a rich language and definitely worth learning. If you really want some pointers your main point of reference should be this link which has many guidelines and pointers in the develop tab. Good luck

Textview scrollable and clickable

I am working on a notepad application for android and it seems I have a litte problem for a textview. Here's the thing: I have a listview of notes, when I click a note, I open another activity which displays the content of my note into a textview. When I click this textview(representing the text from the note), it opens another activity for editing the text (like most of these apps do). The problem is that some of the notes are really long, so I need to make my textview Scrollable. But since I am having a "setOnclickListener" on it, I cannot do that at the same time. I have searched a lot on google and apparently a lot of folks seem to have this problem. Is there a way to achieve my goal?
Ideas:
Use OnGestureListener or OnTouchListener
Use an 'edit' button
Use long press instead of OnClick

popup windows in android?

Pretty new to android so excuse me if this is a really obvious question.
Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a button next to each of these TextViews labeled "modify".
How do I make it so that when I press the modify button next to a certain attribute, a popup window with a space to enter text into comes up so that the user can enter text into this box and then have the actual attribute listing on the original page change? Actually I just need a push in the right direction with creating this popup text field... not sure if there is already some built in functionality for this or if not, what would be the best way to create this kind of thing.
Thanks.
Why not have the modify button set TextEdit.setEnabled(true); and then change focus with TextEdit.setFocus? Note that both of these are inherited from view
If you really want a dialog you might want to looking into the AlertDialog.Builder. I know you can use it with buttons and radio buttons, but I'm not sure you can get it to work with a TextView.
Use a code like this for the input popup: Android dialog input text
In the positive button handler, set your edittext content programmatically like this:
myEditText.setText(value).
As simple as that. The only difference with a standard GUI framework is that you don't retrieve the value as a result of the popup function. Instead, you must provide an action handler.

Categories

Resources