how to use more element in listview? - java

i m new to android .
i m doing my final yr project in android.
Is the any way to use more elements in list view control....
for example: fetch more data frm database and add it at runtime.
the formate may be
text text
text text
text text
text text
etc.....
refer this page for model https://play.google.com/store/apps/details?id=app.diaryfree&feature=search_result#?t=W251bGwsMSwxLDEsImFwcC5kaWFyeWZyZWUiXQ..
(in this page sample image for that application wil be given, like that report i need to display my data.)
is any other control there for that??? how to add runtime more assign more than one element value???
like this
and how to find which row is clicked?
thankz in advance

you can create custom list views to format the listview the way you asked for. And cursors are a good way to fetch data from a database and pass it to a listview. you can use adapters for that.
a sample code for custom list view can be seen here
to find out which item is clicked you need to use onListItemClickListener like given here Android: onListItemClick in Activity

Related

Android Multi Selection Spinner wraps long text

I want to create a multi selected spinner that contains very long text inside each row. I tried creating various styles but just doesn't meet the requirement I'm looking for, can anyone create a multi selection spinner that can wrap long text inside it.
I have already created a spinner that can wrap text inside it, I just want it to be multiselecting.
Any code will be appreciated.

Trouble designing and saving layout with checkboxes programatically

I'm a beginner android developer. I am creating an app but having trouble to get a rough outline for my next task which I am going to explain below. I am not asking for code. I just want to know the best way to do the below.
I have an Activity that displays a RecyclerView with a list of items like this:
My question is related to the 3 checkboxes.
How should I approach creating the layout in the pic? Do I have to include 3 checkboxes and 3 booleans in my main object class? The other items in the object class are saved in SQL database and the RecyclerView in the activity gets its data from there using a cursor. Can the value of the checkboxes be retrieved using the cursor?
Do I create a separate sparseBooleanArray for the checkboxes? Do I create a HashMap for them?
Should I store the value of the checkboxes (Checked/Not Checked) in SQL or SharedPreferences?
This is basically an opinion based question and hence I am throwing some suggestions on how you should implement it. If I have understood your problem correctly, you have provided a single list item in your RecyclerView and the items are being populated from a local sqlite database table.
Hence there are three checkboxes for each of the list item and yes, of course you need to save the states of the checkboxes in your sqlite table along with the information of the list item. I do not know about your current table structure. However, the pseudo implementation of your updated table structure may look something like the following.
item_id description checked_status
----------------------------------------
1 Some desc null (Not checked)
2 Some desc LOCK
3 Some desc DONE
4 Some desc NOTIFY_ME
Hence when you are clicking on your checkbox, you need to update the sqlite table accordingly with the newly updated data for that specific row and update the RecyclerView items accordingly.

How to align data in list view? JavaFX

I have problem with ListView. My application read and parse data from .csv file, then I convert data to array and show in ListView. I need align data like this:
But my solution is this:
Can you help me?
To align your data into columns, i would suggest to use a TableView. You can find an example here:
https://docs.oracle.com/javafx/2/ui_controls/table-view.htm
You can change the look and feel of a TableView to match your needs.
If you like to use a list and not a table you could create a custom list cell. Here is a nice post Custom ListCell with source code which you could easily transfer to your needs.

How to translate ListView texts?

My android application includes ListView binded with SimpleCursorAdapter to the database. This database contains column, which contains data like
somenameofrow
anothername
thirdname
However instead of directly displaying these texts in the ListView, I would like to read according texts (actually - translations) from the Android resources.
How should I do it?
I think that I can use setViewValue for the same, name in the code below is TextView item, which displays my text:
case R.id.name:
TextView elName = (TextView) view;
elName.setText(getApplicationContext().getString(R.string.));
return true;
I am not sure how to understand what is correct id of the resource I am looking for (probably, cursor.getString(columnIndex) or elName.getText()) and how to get the value?
Upd. What if I exclude names from the database and will use ids instead. Will it help?
If you read the android guide ListView tutorial, you will find:
Note that using a hard-coded string array is not the best design practice. One is used in this tutorial for simplicity, in order to demonstrate the ListView widget. The better practice is to reference a string array defined by an external resource, such as with a resource in your project res/values/strings.xml file
Simply create different string-arrays items in res/values-XX, where XX are the locales you want to translate.
See the dev guide for more details about resources and i18n: http://developer.android.com/guide/topics/resources/localization.html
No you can't, since id's are generated in some basically sem-random way during compilation, so you can't be sure which id will have specific String resource.
I would suggest to use translation from DB or you can read translations from assets

get the selected item from list in j2me?

i am working with j2me List.It contain many elements.I want when i select the any of them
i can use it value in my required function.e.g in my code i select a number when i select it
i press a command chat a text area is shown when i write some text there this i can get easily
but how the selected element from list how i can get it .....
<Object Of List>.getSelectedIndex();
You can maintain a Vector which have the same data as filled in List Component.
Now you can get getSelectedIndex and can retrieve object from Vector from the position to get the selected Data.

Categories