..................................................
Name Item Quantity
..................................................
a b 20
b c 80
d f 90
f s 80
.
.
.
In my project, I need to display data like this in a single text view.
This means that all data will be stored in a single string.
Because also need to print same view.
Can you please tell me how I can make this kind of string/output?
Use subString method to split the string using the spaces in between or any logic u preferred and the place the subString values in tableLayout and place images for lines.
It is not efficient using single textview to display all your data.
You can split your data string and then you distribute them into table layout
or you can just use a webview and write your data as HTML in a single string
if you use one of them, you can also keep your data string and you can print as you wish.
Related
FireStore Array
I already retrieve the vaccine name and the number of count but the problem is the SPACE is also replace or being removed.
Retrived
I WANT TO OUTPUT THE ITEM LIKE THIS
WITH SPACE SAME VALUE IN THE FIRE STORE
I ALREADY GET IT USING THIS CODE BELOW IT I HOPE YOU GET THE POINT OF THE CODE BELOW CLICK THE LINKED TEXT TO SEE IT
IMAGE FOR THE CODE
Basically I used the Character.isDigit, isAlphabetic, isWhiteSpace
then save it to stringbuffer. then save it to my textview
I assigned my buffer variable for text to get also the whitespace.
I have one json file, that I imported in parse.com->data browser->import partition. I can get the String and image value from the table but I have no idea about how to get following values. First column have name chapters of type array look like one field following,
[{"__type":"Pointer","className":"Chapter","objectId":"BCr3uAnapV"}]
how to get above value and second column have, name user of type object look like following,
{"password":"xxx"}
Please any one help me for above, I have tried Googling but it did not help.
EDIT:
See following screen shot: arrow display column 1) chapter and have another column 2) user I want to fetch (get ) that for e.g. if we want to get data of String type like: String provider = (String) objectList.get(i).get("provider"); this manner this way I want to above data, below my screen shot:
This line is a relation (of type Pointer) to another Class in Parse:
[{"__type":"Pointer","className":"Chapter","objectId":"BCr3uAnapV"}]
The class being Chapter. You can make sure this object is fetched together with the object pointing to it using "include":
query.include("chapter");
When you query for the other object, using query.include on pointer relations will ensure these related objects are fetched as well.
I'm making a fake command-line system for a fun app, and I want to show the input and output in the same TextView, like this:
>something
>something else
>even more stuff
>etcetera.
I already figured out how to store the text from the EditText into a string and add \n and >, but I can't use strings for the whole thing: to avoid clogging up RAM, I'd like to delete lines after, say 50? I figured that would be much easier to do using Lists.
However, this doesn't work:
log.setText((CharSequence) logText);
But what will?
This method :
http://developer.android.com/reference/android/text/TextUtils.html#join(java.lang.CharSequence, java.lang.Iterable)
return a string composed of each element (either cast as a string or the toString value is used) separated by the delimiter in between each element. You can therefore easily concat all your items in one String.
You can also use http://developer.android.com/reference/java/util/AbstractList.html#subList(int, int)
to limit the count of items in said list.
From your question I assume logText is a List of some sort, therefore you can call
log.setText(TextUtils.join("\n>", logText.subList(0, 50));
Maybe you can put all your strings in a list, an each time you add one, recreate a single string from the list which contains all your items, and affect it to your textview.
You could use a ListView without a separator and populate it using an ArrayAdapter.
That way you wouldn't have to worry about memory, and the user could easily scroll through previous commands.
A stupid question that Im sure is really really simple - ive been trying to fiddle to solve it myself, but its all very new to me so any wisdom would be REALLY appreciated!
With an android application (using eclipse) if I want to compile text for a text view using some data that is stored in a sqlite database (I have a working dbhelper and table I want to use), what do I do?
For example, I want a text box to say something like:
"hello"+#user_name+"its been"+#days+"since your last visit!"
where #user_name and #days are data in a table which I can currently retreive in a list (only 1 value in the list though).
How do i compile a string to be shown in the text view (and assign this string to the view)?
Help!
String textViewValue="hello "+nameList.get(0)+" its been "+daysList.get(0)+" since youy last visit";
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText(textViewValue);
You said you have stored it in arryalist right?
I am not sure if you have one ArrayList or two for Name and Days. (it would be good if you paste some of your code).
If your ArrayList is arrayList then you can get the name atleast like
"hello"+arrayList.get(0); // will retrive first element
Or best way use cursor and fire a query which will store output of following in curser
select Name,Days from your_table where Name='xyz';
then you can use folloing code to retrive data form curser (I am assuming there is only one row in cursor here)
if(cursor.moveToFirst()){
String s = "hello"+cursor.getString(0)+"Its been"+cursor.getString(1)+"days since your last visit!!";
}
now set this s in your textbox.
I have a working android app using TextView, some formatting (line breaks, rows of dashes) and Linkify to generate a primitive "ListView-like" display with clickable URLs in each "row". I'd like to move up to a real ListView, but I'm just not finding the sample/explanation that I need to take that next step.
I have successfully reproduced the HelloListView sample, starting with the hardcoded string array, and moving to a string array defined in my res/values/strings.xml. I've taken one small step toward my goal by adding my HttpClient code to retrieve a set of data from a service, parse the results into a String Array and feed that into setListAdapter() such that my text and links show up as text-only in ListView items.
I want to move to the next step which is to make each "row" in my ListView launch the browser to the URL contained in the data, either by
(A) clicking anywhere in the row, or
(B) clicking a hyperlink displayed within the row data
For option (A), it appears that I need to have my onItemClick() method issue an intent that launches the browser. That's straightforward, but I don't get how to associate the URL with the item (currently its just one part of the string content for each "row" of text). How do I separate my URL from the rest of the text, such that I can launch a browser to the corresponding URL? Do I need to replace my String Array with an array of custom objects?
For option (B), can I use Linkify? It seems that my string array elements get converted to individual TextViews (inferring from the way the Toast text is generated in the HelloListView sample). Do I have access to that TextView to run Linkify against? Do I need to replace my String Array with a TextView Array and run Linkify myself? Am I completely off base?
Thanks to anyone who can help explain back to me what I'm trying to do, in a way that helps to find my way around the SDK, samples and other helps!
How do I separate my URL from the rest of the text, such that I can launch a browser to the corresponding URL?
Use a regular expression (java.util.regex) to find the URL.
For option (B), can I use Linkify?
Yes.
Do I have access to that TextView to run Linkify against?
Yes. Override getView() in your ArrayAdapter. Chain to the superclass and get your TextView from the result of super.getView().
Even better would be to use Linkify on your strings before putting them in the array in the first place.
Do I need to replace my String Array with a TextView Array and run Linkify myself?
No, and that is really not a good idea. Here is a free excerpt from one of my books that goes into more detail on tailoring the individual rows of a ListView, in case this helps.