I had design 5 tabs using Swing. Each tab contains 2 or 3 sub tabs. Now the problem is, at run time the text fields in tabs are overlapping. I use the method
refreshI18NText(jPanelReceivedForm1A)
to refresh the jpanel.
but still I'm getting the problem.
You need to make sure you are using the correct layout manager. The Oracle tutorial is useful for selecting and explaining each layout manager.
http://download.oracle.com/javase/tutorial/uiswing/layout/using.html
Related
I have to create number of buttons and textbox, etc. depending upon a certain number. For ex: if the number = 5, I need to create 5 buttons, and if its value is 10, I need to create 10 buttons.
To achieve such a functionality, the conventional xml GUI won't make it up. I need to develop the GUI dynamically. How can I do that?
Take a look at RecyclerView. You need to apply the DataSet (what u receive dynamclly) and then let the Adapter handle all of the Binding.
Take a look at this tutorial, there are many more.
Notice that you will need to create TWO Viewholder (button and a textview) and override the getItemViewType
Add a Linear/Relative layout in xml and on run time according to given number add view(buttons and text views) in this layout.
See this tuts:
https://androiddesk.wordpress.com/2012/08/05/creating-dynamic-views-in-android/
http://www.javacodegeeks.com/2012/09/android-dynamic-and-xml-layout.html
I want to create a layout that looks like this:
So a few different categories and in each of that, 4 elements should be positioned.
I have tried to make a ScrollView first (because it should be possible to scroll) and then having vertical and horizontal LinearLayouts nested into each other. But it doesn't work.
I don't want to use the GridLayout because this requires API 14 and higher, and my app should work for the API 10 or lower.
Can anyone help?
It is an example of a type of custom ListView.So instead of what you are doing now, try creating a custom adapter for adding labels and buttons to each of your row items within the list as per your needs you have given in your diagram link.
Learn more about it here
My target is to display an abbreviation list with two entries per line: the abbreviation and the corresponding long version. For a nice layout I used a GridPane because of the vertical alignment over all entries - it's nice to read.
But I also want to scroll to the clicked abbreviation and set the focus on it like in a ListView version of it.
For example the # on page links in good old HTML. Is there another javafx layout element I miss to achieve this?
I don't believe there is a provided control that will work for the specific scenario you are describing. However, I think one of these options might work for you...
Use the TableView control and add two columns for the information you want to show (one for the abbreviation and another for the long version). TableViews also have the scrollTo and setFocus functionality you're looking for. Here is a good resource to get you started with the Tableview control. You can also style the Tableview with CSS to look less like a table and more like a list if thats what your intention is.
The second option is to set a custom cell factory on your ListView that builds custom cells using HBoxes, VBoxes, Labels, etc. to achieve your desired look. You would also want to use the cell factory to populate each ListView cell with an object that contains both the abbreviated text and long version text. A couple good resources, 1, 2
Although I think both option will work fine, I would suggest option 1 since in option 2 you are sort of building a table type structure anyway. I hope this is helpful!
Simple aim:
To have default buttons in the navigation bar of my ActionBar with the text centre aligned. I simply want to use the default, simple way of:
ActionBar.Tab myTab = Actionbar.newTab()
myTab.setText("my tab's text");
What's the problem
I cannot find any simple way to do this whatsoever. You can't access the views (as ActionBar.Tab.getCustomView() always returns null due to it being the default view). There is no method that I can see in ActionBar, ActionBar.Tab, etc to get the current view, get or modify LayoutParams (especially Gravity). A visualisation of the problem is below (one line seems to work right, but double lined navigation buttoms definitely seem left aligned):
Unideal solution
Am I right in negatively thinking that the only way to accomplish this is to use custom views for all of my tabs, somehow guess / attempt to copy the default formatting for the tabs (as I can't find anyway to access these views) and assume / hope that the default formatting / font / style of ActionBar.Tab's text does not change any time soon?
Surely there has to be a better way?
AFAIK, there's no way you can access the Views in ActionBar. Using custom layout seems the only solution. However, doesn't Android align the text to center automatically? It apparently does so in all my applications.
please download the follwing example. it will help you. i am sure i take help from this demo.
https://github.com/JakeWharton/ActionBarSherlock
I'm trying to make an android app (I'm new in the Android programming world), and I'm having problems creating the GUI.
The point is that I get information of some data that is divided in days... The problem is that I don't know, until I retrieve the information, how many days the GUI should display.
http://img574.imageshack.us/img574/3787/mainscreen.jpg
The grey part will be a TextView, and, also, the black part will be another TextView with multiple lines.
So, the point is, how can I do to have multiple TextView's without knowing before the exact number? I suppose that I can't declare them in the layout.xml
The only solution that I've been thinking about is to create in the layout 7 pairs of TextView and, when I know the exact number, just use what I have to, and don't use the others... (It's a bad solution)
What do you suggest?
Thank you for your answers!
You should create a ListView, which inflates TextView for the items you have.
You can use this example of how to create sectioned ListView, which will look exactly like you want.
I'm not familiar with Android, so other people may offer better, more specific advice.
In the environments I'm familiar with, the problem of displaying an unknown number of items is solved by using not a series of display elements for each data item but a list control. The list component will display as many items as you give it, and can usually be modified to have different appearance for different data, so you're flexible in making it as pretty as you want.
Well you can consider this one also,
Create a table layout in XML, give it a id: TableLayout table=(TableLayout)findViewById(r.id. ....)
Create dynamic TextViews using: TextView day=new TextView(this); day.setText(day name);
Now add this text view to your table layout : table.addView(day);
Run the code for textView creation and addition to table in loop
Hope this helps...............