I apologize for yet, another beginner question. I have a .Net background and this is my first time with Android.
In .Net I could use panels to show/hide controls, and I'm looking to do the samething in Android.
This is what I'm trying to do: There will be two radio buttons on the top: Basic and Advanced. Depending on the radio button clicked, I want to show the relevant form. How can I possibly accomplish this?
Thanks!
you can use setvisibility for the view
you have to register for CheckedChangeListener using setOnCheckedChangeListener for the radiogroup
In the onCheckedChanged
you have to do
hidingView.setVisibiliity(View.GONE)
showingview.setVisibility(View.VISIBLE)
You could just put each one of your forms into its own FrameLayout and then use a conditional statement that checks for the state of the radio buttons. I dont know what kind of format your forms are in but Im imagining theyre probably a series of edittext boxes and TextViews. It would probably be easiest if you set it up your xml layout, declare the view to place one form and then add the other forms content to the FrameLayout dynamically in java according to the radio buttons pressed.
Related
First I want to mention that I am a beginner in android.
Basically I am trying to implement the Microsoft's calculator in android.For now I am implementing only the UI.
Is it possible to make a dropdown list of buttons?
Like in this picture when you select Bitwise a list of buttons appears.Also is it possible Bitwise also to be a button and if not to act like one?
Yes, it is possible.
you must use a custom spinner.
By custom spinner, you can add any layout you like to your spinner; so you can create a layout that has a button.
You can search for Android custom spinner and learn about that.
I will give you an educational link about that.
How to add Custom Spinner in android?
I'm currently developing a note taking app. One of the requests for the app is to be able to put checkboxes (clickable, checkable) anywhere into the text like Evernote allows.
I know you cannot simply just put Views into the EditText widget. Also, the solution has to be able to serialize into a database and able to be loaded to the same formatting as it was left.
Is there a way to achieve this behaviour in normal EditText? I welcome every idea that might lead to a solution.
Have you seen rich editor library? It has a ton of functionality, including checkboxes inside EditText. I guess this one is exactly what you're looking for.
Why don't you use the CheckBox view available with android?
<CheckBox
android:id="#+id/checkbox_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:onClick="changeCheckboxState"
android:text="Task 1" />
Implement the changeCheckboxState() method in your code to change checked state by using checkbox.setChecked(true) which will achieve what you want -
This way you can create a ListView/RecyclerView and attach this checkbox item to a custom adapter and keep a track of the state of the checkbox in you database
Further if you want to customise the look of your checkbox to resemble Evernote you can put it in a Linear Layout with other buttons to the right of the text in the checkbox.
I want to have a button like the one in the link below. How can i achieve it just by java code or xml? By the way it's going to be of a different color when pressed. I've explored similar posts but none helped. Any help appreciated.
The button which i want
Just make a View with large rectangle and add what you want(e.g. Label contains 'Number Of Students' and/or something else) in the view.
Then, add onClickListener to the View.
To change clicked colour, refer to here
Assuming some logic that deals with measure units and the user is asked to choose between US and metric systems, what would be the better UI choice: using 2 CheckBoxes or RadioButtons? Is there an easy way to ensure just one View is checked?
Checkboxes are useful when you want the user to select multiple options.
Radio buttons are useful to guarantee a single option among multiple options. However, if you have a fair amount of radio buttons the user interface becomes a mess. Therefore, for those cases, Spinners are the best answer for your problem.
If you use Radio Buttons you can guarantee they only use one radio button using RadioGroups.
I would use a Spinner if I were you. It'll allow you to add other unit systems in the future.
Through radio button group you can do it. Just use a RadiobuttonGroup widget mention your radiobutton properties.
Simple. If you can't follow some of procedures I suggest going and look for tuts on them
First: Go to your xml file
Second: Create Radio group
Third: Create Radio button in between
Forth: make sure you have the id of the radio button.
fifth: call the item on your main class. RadioButton name = (RadioButton)findViewById(R.id.radioButton Name);
Now you can program the rest everything really just follows this order for anything in .xml. You need it call it and create and ID simple. Next time just look at youtube vids. I recommend the website TheNewBoston.org best tuts you'll ever encounter in a life time for almost all programming languages.
I have a layout of a user entry form.when i enter username and password and hit the submit button.the content should be saved and another div with three textboxes and editboxes should appear in the same page.
Replacing the content might not be the best solution.
Anyway, you can create all these elements together in the same layout and set the "div with three textboxes and editboxes" initially to "hidden".
After you have clicked the button and triggered the desired event, you grab the desired elements and make them visible while setting the unwanted elements to hidden again.
Charles Merriams answer would be the more elegant and cleaner way, this only answers the "base" question.
The magic word you need to look at is "Intent". You call your own application in order to switch layouts after the submit button.
You may find the Notepad tutorial useful.
You can try what DrColossos said or you can try by just setting a different contentview on button click.