​
Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Monday, 24 July 2017

Create styling string from resources

Create styling string from resources


This example show how to create partial styling string from resources:


Edit values/strings.xml to add string resources with styling:
<resources>
<string name="app_name">AndroidStylingStringResources</string>
<string name="normal_name">It is Normal String</string>
<string name="italic_name">Partial <i>Italic String</i> from resources</string>
<string name="bold_name">Partial <b>Bold String</b> from resources</string>
<string name="underline_name">Partial <u>Underline String</u> from resources</string>
</resources>


Edit layout/activity_main.xml to use the string resources:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context="com.blogspot.android_er.androidstylingstringresources.MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_margin="20dp"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold"/>
<TextView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="28dp"
android_text="@string/normal_name"/>
<TextView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="28dp"
android_textStyle="italic"
android_text="Whole TextView in italic style"/>
<TextView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="28dp"
android_text="@string/italic_name"/>
<TextView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="28dp"
android_text="@string/bold_name"/>
<TextView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="28dp"
android_text="@string/underline_name"/>

</LinearLayout>



{ Read More }


Friday, 21 July 2017

Create a comma separated string in shell a b c a b c no not sed

Create a comma separated string in shell a b c a b c no not sed


Well, the title does not really explain the real issue but I couldnt find a better one.

Another try: assume you have a list of tokens in a shell script and you want to build a comma separated list out of those tokens and you want to do this in a loop there is usually an issue with one comma too many at the beginning or at the end.

For simplicity I use a simple token list.
This example of course could be solved faster with sed.
I add a more complex example at the end.

A first approach is as follows and will create a list with an empty first element so to speak:
TOKENS="a b c" LIST="(" for token in $TOKENS ; do LIST="${LIST},${token}" done LIST="${LIST})" echo $LIST (,a,b,c) 
So how does one get rid of the extra empty element at the beginning of the list?

One might add an if-statement:
TOKENS="a b c" LIST="(" for token in $TOKENS ; do if [ "x$LIST" = "x(" ] ; then LIST="${LIST}${token}" else LIST="${LIST},${token}" fi done LIST="${LIST})" echo $LIST (a,b,c) 
In my search for a shorter one line solution I found the following approach using shell paremeter substitution.
TOKENS="a b c" LIST="" for token in $TOKENS ; do LIST="${LIST:-(}${LIST:+,}${token}" done LIST="${LIST})" echo $LIST (a,b,c) 
This is admittedly not easy to understand on the first glance unless you are very familiar with the parameter substitution.
Im using the complementary idea of :- and :+ .
${LIST:-(} will put out either the current value of LIST (if it exists and is not empty) or a ( .
So in the first invocation of the loop LIST is not yet set and thus ( is put out.
In the next rounds LIST is set and will be put out as is.
${LIST:+,} will put out either a comma (if LIST exists and is set) or nothing at all.
In the first invocation of the loop LIST is not yet set and nothing is put out.
In the next rounds LIST is set and a comma will be put out.

In all cases the token is appended at the end.

Here is a an example with more complex tokens which contain a space and they should be surrounded by quotes in the resulting list.
A="sam smith" B="jane jones" C="gabe miller" LIST="" for token in "$A" "$B" "$C" ; do LIST="${LIST:-(}${LIST:+,}${token}" done LIST="${LIST})" echo $LIST (sam smith,jane jones,gabe miller) 
{ Read More }


Tuesday, 20 June 2017

CONVERT STRING TO INTEGER OBJECTIVE C by Little

CONVERT STRING TO INTEGER OBJECTIVE C by Little


Name:String To Integer Objective C Converter
File size:25 MB
Date added:November 20, 2013
Price:Free
Operating system:Windows XP/Vista/7/8
Total downloads:1046
Downloads last week:87
Product ranking:★★★★★










She was advised by him to come back at once. Could you tell me the way? I wonder who started that rumor. I wish I had been there with you. Take anything you want. When is the next flight to Delhi? He really likes traveling a lot. I want an MP3 player! You are in favour of ... arent you? Will she get well soon?
String To Integer Objective C Converter: - My mother asked me not to feed the dog until after we had all eaten.
- I have one brother.
- I have to go to the police station.
- I have a cold now.
- Something must have happened to him on the way.
- There was a light rain yesterday.
- Oh, really? Thank you. That would help a lot.
- What is Ken eating?
- They might be taller than you.
- CONVERT STRING TO INTEGER OBJECTIVE C
- Lets take a trip.
She bit him. Could you draw a map for me? She devoted herself to him. How is your dad? Did you have a fight with Ken? That is an old camera. Dont throw garbage away here. Can I have your number please? She handed him a book. Show me how to do it, please.






String To Integer Objective C Converter charts






String To Integer Objective C Converter location




String To Integer Objective C Converter google search
String To Integer Objective C Converter ask google support
String To Integer Objective C Converter chrome extensions
String To Integer Objective C Converter for android
String To Integer Objective C Converter videos
String To Integer Objective C Converter twitter search
String To Integer Objective C Converter wiki
String To Integer Objective C Converter photos


String To Integer Objective C Converter world






String To Integer Objective C Converter youtube videos






String To Integer Objective C Converter bing photo search




String To Integer Objective C Converter, Inc. 80176 Fayetteville Street, North Carolina 4009 - USA, CA 28309 Tel: 436-320-3968 - Fax 348-370-3915 E-mail:Jeffery_Little@gmail.com
String To Integer Objective C Converter address




String To Integer Objective C Converter


String To Integer Objective C Converter world
{ Read More }