<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3669293961729061947</id><updated>2025-05-18T18:15:17.314-07:00</updated><category term="android app"/><category term="ListView"/><category term="Thread in android"/><category term="progressbar"/><category term="3d effect"/><category term="Android kannada keyboard"/><category term="Android kannada keyboard with transliteration"/><category term="Custom view in android"/><category term="DatePicker"/><category term="EMI calculator app"/><category term="FD calculator app"/><category term="Floaging label"/><category term="Hindi keyboard"/><category term="Hint"/><category term="Indian newspapers"/><category term="Kannada keyboard"/><category term="Kannnada keyboard"/><category term="Shuffling a list"/><category term="TextInputLayout"/><category term="add rate the app"/><category term="android compilation error"/><category term="android import error"/><category term="black selected items in listview"/><category term="calendar"/><category term="clipboard"/><category term="copy to clipboard"/><category term="countdowntimer and progressbar"/><category term="custom view error"/><category term="custom view in xml file"/><category term="date"/><category term="drawables"/><category term="elevation in android"/><category term="finance app"/><category term="home navigation with toolbar"/><category term="horizontal progressbar"/><category term="hundred"/><category term="kannada in android"/><category term="kannada transliteration"/><category term="landscape orientation"/><category term="layer drawable in android"/><category term="list fragment"/><category term="other apps by me"/><category term="progress dialog"/><category term="puzzle app"/><category term="rate the app"/><category term="select textview"/><category term="send feedback"/><category term="shadows for views"/><category term="share textview content"/><category term="shataka"/><category term="simpledateformat"/><category term="spinners"/><category term="sqlite database access"/><category term="sqlite table creation"/><category term="support actionbar"/><category term="test your memory"/><category term="toolbar"/><category term="using sql database in android"/><category term="women&#39;s safety"/><title type='text'>Android Coding Tips</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>59</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-1914047237961740815</id><published>2017-11-21T09:15:00.001-08:00</published><updated>2017-11-21T09:15:41.161-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clipboard"/><category scheme="http://www.blogger.com/atom/ns#" term="copy to clipboard"/><category scheme="http://www.blogger.com/atom/ns#" term="select textview"/><category scheme="http://www.blogger.com/atom/ns#" term="share textview content"/><title type='text'>Copy to clipboard</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In my upcoming app, I have codes which I display. These are some times lengthy, and I want the app to be able to copy this to clipboard. Once it is in clipboard, users can paste it anywhere.&lt;br /&gt;
&lt;br /&gt;
So how do you copy some text from your app to clipboard.&lt;br /&gt;
&lt;br /&gt;
You need to use clipboard manager.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Clipboard Manager&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This class sets and gets data for the clipboard using Clipdata objects.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
You can get the object of this class using system service.&amp;nbsp; - using statement&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
context.getSystemService(Context.CLIPBOARD_SERVICE)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Example&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I have a dummy project with a button, onclick of which copies content to clipboard.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here is my activity file&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;package&lt;/span&gt; com&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;hegdeapps&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;testapp&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.content.ClipData&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.content.ClipboardManager&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.support.v7.app.AppCompatActivity&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.os.Bundle&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.view.View&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.widget.Button&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold;&quot;&gt;android.widget.TextView&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;MainActivity&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;extends&lt;/span&gt; AppCompatActivity &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;

    &lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        setContentView&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;activity_main&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        String str &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;The 7 Cs of communication provide a checklist for making sure that your meetings  , emails  , conference calls  , reports  , and presentations   are well constructed and clear – so your audience gets your message.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;According to the 7 Cs, communication needs to be:\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Clear.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Concise.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Concrete.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Correct.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Coherent.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Complete.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;    Courteous.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;In this article, we look at each of the 7 Cs of Communication, &quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;
                &lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;and we&#39;ll illustrate each element with both good and bad examples.\n&quot;&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

        TextView tv &lt;span style=&quot;color: #333333;&quot;&gt;=(&lt;/span&gt;TextView&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;textview&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        tv&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;setText&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;str&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;

    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;copyToClipboard&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;View v&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt;
    &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        ClipboardManager manager &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;ClipboardManager&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; getSystemService&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;CLIPBOARD_SERVICE&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        TextView tv &lt;span style=&quot;color: #333333;&quot;&gt;=(&lt;/span&gt;TextView&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;textview&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        String str &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; tv&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getText&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
        ClipData data &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; ClipData&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;newPlainText&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;ds_soln&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; str&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        manager&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;setPrimaryClip&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;data&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Now the layout file for this activity is shown below.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
  &lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/button&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:onClick=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;copyToClipboard&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Copy Text&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt; 
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/textview&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Now on click of copy button the entire string is copied to clipboard.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Selecting text and copying&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Some times users find part of our code interesting. They don&#39;t want the entire text. You see this in all the browsers. You select text by long clicking on it and grabbing the two end points. And you can copy the text or share it.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
How do you make your app behave like this?&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Simple. Just make the textview selectable.&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;
       &lt;span style=&quot;background-color: #f9cb9c;&quot;&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;android:textIsSelectable=&lt;/span&gt;&quot;true&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/textview&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
And now your text is selectable, copyable and shareable. Great!!!.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqHi4tk4PTVKvr-sa8kHgIsHbypYd6WqivEfFXGIUPaZeoAPl2WYilgRFCBxDeShW7V5gCpJVc8trnOIdBIwYrf1UCkM1eCYraXcs-zzNqF1R3fiEDuP3GyqAsaad41VZ7_bZ6zp65DfE/s1600/device-2017-11-21-194235.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;720&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqHi4tk4PTVKvr-sa8kHgIsHbypYd6WqivEfFXGIUPaZeoAPl2WYilgRFCBxDeShW7V5gCpJVc8trnOIdBIwYrf1UCkM1eCYraXcs-zzNqF1R3fiEDuP3GyqAsaad41VZ7_bZ6zp65DfE/s400/device-2017-11-21-194235.png&quot; width=&quot;225&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span id=&quot;goog_1034337263&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1034337264&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/1914047237961740815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/11/copy-to-clipboard.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1914047237961740815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1914047237961740815'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/11/copy-to-clipboard.html' title='Copy to clipboard'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqHi4tk4PTVKvr-sa8kHgIsHbypYd6WqivEfFXGIUPaZeoAPl2WYilgRFCBxDeShW7V5gCpJVc8trnOIdBIwYrf1UCkM1eCYraXcs-zzNqF1R3fiEDuP3GyqAsaad41VZ7_bZ6zp65DfE/s72-c/device-2017-11-21-194235.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-1126948458328677365</id><published>2017-11-09T21:57:00.003-08:00</published><updated>2017-11-09T21:57:40.621-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android app"/><category scheme="http://www.blogger.com/atom/ns#" term="hundred"/><category scheme="http://www.blogger.com/atom/ns#" term="shataka"/><title type='text'>Hundred - a number game updated</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.shataka&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.shataka&quot; border=&quot;0&quot; data-original-height=&quot;988&quot; data-original-width=&quot;1280&quot; height=&quot;492&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7sq140f5I8EahNoxqfxv73b1hLrhxKOjUCSq8yjN7-w1b2L9G7COP0rpkr9Nwbg8tOGKTfYD0zgIFO-2PrdJxvDtQst1-TPhKaOMhhTFmvO-2ksMU9vQiobE0x71viaqstnIgQ8CwQls/s640/mockupl1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
Shataka - my number game which is very simple but really good, has been updated.&lt;br /&gt;
&lt;br /&gt;
First of all, its name is changed to &quot;Hundred&quot;. Because that is the aim of the game, right?&lt;br /&gt;
&lt;br /&gt;
There are some UI changes too. May be for better :) :)&lt;br /&gt;
&lt;br /&gt;
And I have added a how to section, which guides the user step by step.&lt;br /&gt;
&lt;br /&gt;
The game has a grid of 9 cells , 3 rows and 3 columns. The aim of the game is to fill this grid with&amp;nbsp; numbers so that each row and each column adds up to 100. And all the required numbers are given at the bottom of the grid.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqBydOm3UH6qY8_QuI3WP9FxI0j3g8X9w13uZWJKisSNEd3ZLhPokGV0PSZDRCwCTERM1xu1o3i1IFK2Bo0ZbMwf0VpLIS5hsDJCnwvszMu0UukPWUj9mMOdmjflNC7vVUqmeBLj2j2mQ/s1600/l1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;818&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqBydOm3UH6qY8_QuI3WP9FxI0j3g8X9w13uZWJKisSNEd3ZLhPokGV0PSZDRCwCTERM1xu1o3i1IFK2Bo0ZbMwf0VpLIS5hsDJCnwvszMu0UukPWUj9mMOdmjflNC7vVUqmeBLj2j2mQ/s400/l1.png&quot; width=&quot;202&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In this version( v 3.0), in level 1,&amp;nbsp; 6 numbers are already provided in the grid. (In older versions 3 numbers were filled in the grid). So user needs to fill only 3 more numbers. So level 1 is pretty easy. You can see that in the above screen shot, 2nd row and 3rd column are already filled and their sums are 100. &lt;br /&gt;
&lt;br /&gt;
In level 2, 5 numbers are provided and user should fill the remaining 4. And so on.&lt;br /&gt;
&lt;br /&gt;
From level 8 onwards, the game is slightly more challenging. Now the sum is different each time, its value is shown at the top of the grid.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjshvFdOkHc-S1pf_e3yIt6aV48hnzk5oyYMfT7rs47oqYlAPOk7dm3_-87toFEPhSANetF-YpzehwqMxOsMHCx2LT5_4AyI4DVGwm2GKEeyTYmSB4U3GLPpCurohnQH_byoA2ZneRYCEQ/s1600/random.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;818&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjshvFdOkHc-S1pf_e3yIt6aV48hnzk5oyYMfT7rs47oqYlAPOk7dm3_-87toFEPhSANetF-YpzehwqMxOsMHCx2LT5_4AyI4DVGwm2GKEeyTYmSB4U3GLPpCurohnQH_byoA2ZneRYCEQ/s400/random.png&quot; width=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
From level 15, the sum should be 1000.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb_9tQXibuoObcxpkTSt_OofVyss5hrYOJW7woEXivRtT1AAzag58LU0gt6eUjsfRxEAg4DlVK7JkYSZSbHvty_AWKRRP4FJSoPgv8D0V93eK8DYk6e-ud9akVhYEqLtVryqLcH_-B29g/s1600/thou.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;818&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb_9tQXibuoObcxpkTSt_OofVyss5hrYOJW7woEXivRtT1AAzag58LU0gt6eUjsfRxEAg4DlVK7JkYSZSbHvty_AWKRRP4FJSoPgv8D0V93eK8DYk6e-ud9akVhYEqLtVryqLcH_-B29g/s400/thou.png&quot; width=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
I think, better than you explaining the concepts, it is better you &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.shataka&quot; target=&quot;_blank&quot;&gt;download&lt;/a&gt; it and see it for yourself.&lt;br /&gt;
&lt;br /&gt;
OK, I used mockupsjar to create some nice screen frames. But you should know that, android studio provides with option of frames when you are taking screen shot. All screen shots except for first one were created using android studio.&lt;br /&gt;
&lt;br /&gt;
If you are looking for a place to create feature graphic - you know that it is essential, norio site lets you create the feature graphic. But I used GIMP instead,&lt;br /&gt;
&lt;br /&gt;
And do not forget to select both check boxes when you are trying to create a release version apk and studio asks you whether you want to sign jar files or entire apk.&lt;br /&gt;
&lt;br /&gt;
And after you shrink the files using proguard, you may need to use few &quot; -keep&quot; lines in your proguard.txt file. I was unable to drop numbers into cells in my release version! &lt;br /&gt;
&lt;br /&gt;
&lt;span id=&quot;goog_1742505309&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1742505310&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/1126948458328677365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/11/hundred-number-game-updated.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1126948458328677365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1126948458328677365'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/11/hundred-number-game-updated.html' title='Hundred - a number game updated'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7sq140f5I8EahNoxqfxv73b1hLrhxKOjUCSq8yjN7-w1b2L9G7COP0rpkr9Nwbg8tOGKTfYD0zgIFO-2PrdJxvDtQst1-TPhKaOMhhTFmvO-2ksMU9vQiobE0x71viaqstnIgQ8CwQls/s72-c/mockupl1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-8369772463327229583</id><published>2017-09-12T07:39:00.001-07:00</published><updated>2017-09-12T07:39:49.001-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="list fragment"/><category scheme="http://www.blogger.com/atom/ns#" term="ListView"/><title type='text'>Using a list fragment with cursor adapter</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
All these days, I avoided using fragments. But then I realized for my this particular applications fragments are ideal. I have a master - detail list in my app.&lt;br /&gt;
Let us say you want to have two fragments - one is a fragment which contains a list of elements and second one expands one element of the list. Both of them share the same cursor from the activity.&lt;br /&gt;
&lt;br /&gt;
Let us start with list fragment.&lt;br /&gt;
&lt;br /&gt;
Do not try creating list fragment using a wizard. It unnecearrily adds too many methods and classes.&lt;br /&gt;
&lt;br /&gt;
Let us start writing our own fragment like this&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;MyListFragment&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;extends&lt;/span&gt; ListFragment&lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;

&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Next using code menu override option, override the following method&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt; &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This method should be used for inflating the layout file for the fragment.&amp;nbsp; I have a framelayout in parent activity of this fragment with the id as container. So I will specify that for inflating. The framelayout will be the parent viewgroup for fragment.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; View &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onCreateView&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;LayoutInflater inflater&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; ViewGroup container&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;return&lt;/span&gt; inflater&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;inflate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;listfragment&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;container&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
 &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
R.layout.listfragment is my layout&amp;nbsp; file which for the fragment. Here it is&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;vertical&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;ListView&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@android:id/list&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@android:id/empty&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;No items in list&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Note that the ids of both ListView and TextView are android ids. This is needed because we want to use listfragment methods for most of our works, instead of getting listview with the help of findviewbyid etc.&lt;br /&gt;
&lt;br /&gt;
How about the adapter for the list? I am having a database cursor for my list. So I can use simple cursor adapter. The adapter should be set in &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;onActivityCreated&lt;/span&gt;() method.&lt;br /&gt;
&lt;br /&gt;
Where is the cursor for the adapter? Instead of trying to fetch the cursor all over again, you can access the cursor from the activity. (Make sure it is not private). Using &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;getActivity&lt;/span&gt;() and typecasting it to parent activity name, you get access to parent activity. Next you access cursor from there.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onActivityCreated&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Nullable&lt;/span&gt; Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;onActivityCreated&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        MyActivity act &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;MyActivity&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; getActivity&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
        mCursor &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; act&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;mCursor&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        SimpleCursorAdapter adapter &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; SimpleCursorAdapter&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;act&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;
                android.R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.simple_list_item_1&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; mCursor&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;
                &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; String&lt;span style=&quot;color: #333333;&quot;&gt;[]{&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;},&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;[]{android.&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.text1&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;},&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        setListAdapter&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;adapter&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
OK. The first parameter to SimpleCursorAdapter is context. Second parameter is the layout for each row of the list. You can use android.R.layout.simple_list_item_1. Or you can write your own layout file.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Third parameter is cursor. And fourth and fifth are mapping of columns in cursor to views in listview. &lt;br /&gt;
&lt;br /&gt;
Now how do we handle item clicks?&lt;br /&gt;
&lt;br /&gt;
You can write an interface in the fragment. And when item is clicked from list, call the function of this interface. Now the parent activity must implement this interface in order to listen to itemclick of this fragment.&lt;br /&gt;
&lt;br /&gt;
Let us write the interface.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;package&lt;/span&gt; your&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;package&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;interface&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;OnListItemSelectedListener&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;OnItemSelected&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; position&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Create an instance of this interface in onActivityCreated method. Developers tutorial asks you to create call back instance in onAttach() method. I faced some difficulties. So I am writing it in onActivityCreated() method like this.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onActivityCreated&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Nullable&lt;/span&gt; Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;onActivityCreated&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        ........
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
            mCallback &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;OnListItemSelectedListener&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; act&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;ClassCastException e&lt;span style=&quot;color: #333333;&quot;&gt;){&lt;/span&gt;
            Toast&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;makeText&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;act&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Class must implement OnListItemSelectedListener&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;Toast&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;LENGTH_SHORT&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Now the thing remaining is how do we use this interface.&lt;br /&gt;
&lt;br /&gt;
Override the OnListItemClick() method of ListFragment and here call the OnItemSelected method of interface. &lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onListItemClick&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;ListView l&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; View v&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; position&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;onListItemClick&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;l&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; v&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; position&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; id&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;mCallback&lt;span style=&quot;color: #333333;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; mCallback&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;OnItemSelected&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;position&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
OK. Now our onclick method is ready to go to the parent activity.&lt;br /&gt;
&lt;br /&gt;
Parent activity needs few lines of code.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;MyActivity&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;extends&lt;/span&gt; FragmentActivity &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;implements&lt;/span&gt; OnListItemSelectedListener &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt; 
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; MySqliteHelper mSqliteHelper&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; mPos&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; MyListFragment fragment&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
 
        &lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
            setContentView&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.listact&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
            mCursor&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;mSqliteHelper&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getallrows&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;  
            fragment &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;MyListFragment&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt; 
            getSupportFragmentManager&lt;span style=&quot;color: #333333;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;beginTransaction&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;list_container&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,fragment&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;commit&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt; 
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
In order to use Fragments with support library, you need to extend your class from FragmentActivity.&lt;br /&gt;
&lt;br /&gt;
Here is the layout file of the activity - R.layout.listact&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;vertical&quot;&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt; 
  
        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;FrameLayout&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginLeft=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;5dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginRight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;5dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/list_container&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt; 
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
In oncreate method of&amp;nbsp; we are fetching the cursor and then creating a fragment and adding it to frame layout.&lt;br /&gt;
&lt;br /&gt;
Notice that we are implementing the interface here. Android studio forces you to implement the method of the OnListItemSelectedListener interface. We complete its code.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;OnItemSelected&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; position&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        mPos &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; position&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
       //do something
    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/8369772463327229583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/09/using-list-fragment-with-cursor-adapter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/8369772463327229583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/8369772463327229583'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/09/using-list-fragment-with-cursor-adapter.html' title='Using a list fragment with cursor adapter'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-4095931404422237463</id><published>2017-07-21T05:00:00.002-07:00</published><updated>2017-07-21T05:00:52.869-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android app"/><category scheme="http://www.blogger.com/atom/ns#" term="EMI calculator app"/><category scheme="http://www.blogger.com/atom/ns#" term="FD calculator app"/><category scheme="http://www.blogger.com/atom/ns#" term="finance app"/><title type='text'>Financial Calculator published</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Today I have published my 7th app &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.savings&quot; target=&quot;_blank&quot;&gt;Financial Calculator&lt;/a&gt; in google play. (you will see 8 apps in market page. But Kannada Hindi keyboard is no longer supported as &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.aksharakeyboard&quot; target=&quot;_blank&quot;&gt;Akshara keyboard&lt;/a&gt; is its successor.)&lt;br /&gt;
&lt;br /&gt;
This app is meant for us Indians who want to save our money a little bit in FDs and RDs. Or/and pay EMI each month for housing and other loans. The app can calculate EMI amount, FD or RD maturity value. (So you can correct the bank official if they make a mistake :) )&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUuyPIBVX2Go06tuIOcXbDoRMBkSI02Ra5Ng1LbKkajspzskFATeHEObDc-kb0ydMqSfG4Gbpj0GuCRmEigrV3nJJCz4yCp2AATE3VscXIbITFbhoCYbmcs2hZMV7uDJT_9lXcvYM1Vsk/s1600/sc5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;720&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUuyPIBVX2Go06tuIOcXbDoRMBkSI02Ra5Ng1LbKkajspzskFATeHEObDc-kb0ydMqSfG4Gbpj0GuCRmEigrV3nJJCz4yCp2AATE3VscXIbITFbhoCYbmcs2hZMV7uDJT_9lXcvYM1Vsk/s320/sc5.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
It will also calculate how much will you pay extra for the loan. It lets you compare two loans, compare two FDs or RDs.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYr-Vz8dAuU3TBJ7dX4KJxDpDJYSjRLx3elFX8-13x9S_fQ1QkVjN_oHKlgkG9Xfz2VnQYo5dd6xdRJVsVfL6kJx09OtaSiBNP8Pk-FiEyTMkL2aTULMLGTev5t-j3IQCXFGITLdNIX-c/s1600/sc1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;720&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYr-Vz8dAuU3TBJ7dX4KJxDpDJYSjRLx3elFX8-13x9S_fQ1QkVjN_oHKlgkG9Xfz2VnQYo5dd6xdRJVsVfL6kJx09OtaSiBNP8Pk-FiEyTMkL2aTULMLGTev5t-j3IQCXFGITLdNIX-c/s320/sc1.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwEVxjGPKbMwD8Dhbly7qUrud6_h2ENFl7RAAaN8jh81ib0-cqFt5WcJE5VThzmd3yDa-ZtWkyGK8I45D8GRtNqWVHaW2kjq7hxVvfmaK2hz9Pj6T3HT-yjZMq9seobY22LJ2Cto2uGbQ/s1600/sc3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;720&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwEVxjGPKbMwD8Dhbly7qUrud6_h2ENFl7RAAaN8jh81ib0-cqFt5WcJE5VThzmd3yDa-ZtWkyGK8I45D8GRtNqWVHaW2kjq7hxVvfmaK2hz9Pj6T3HT-yjZMq9seobY22LJ2Cto2uGbQ/s320/sc3.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There are other calculations too. Gratuity calculator, loan afford&lt;br /&gt;
ability calculator, savings goal calculator and currency converter.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhT8VBS6Ej_V4FSJqWZBhfVNwLjt1KaPBnwvXJSjWTejb4-kMyd_V9h8g5qtONSIBkKSWxTK7RpDpw5ZXTUBAULTl-2JHZZxwJ3DR5R4XTcthq-rgRw4jn2SFKhdsoETU83DfVGoql0Vg/s1600/sc2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;720&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhT8VBS6Ej_V4FSJqWZBhfVNwLjt1KaPBnwvXJSjWTejb4-kMyd_V9h8g5qtONSIBkKSWxTK7RpDpw5ZXTUBAULTl-2JHZZxwJ3DR5R4XTcthq-rgRw4jn2SFKhdsoETU83DfVGoql0Vg/s320/sc2.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
So what are you waiting for? &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.savings&quot; target=&quot;_blank&quot;&gt;Download app&lt;/a&gt; today and give me your valuable feedback. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/4095931404422237463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/07/financial-calculator-published.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4095931404422237463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4095931404422237463'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/07/financial-calculator-published.html' title='Financial Calculator published'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUuyPIBVX2Go06tuIOcXbDoRMBkSI02Ra5Ng1LbKkajspzskFATeHEObDc-kb0ydMqSfG4Gbpj0GuCRmEigrV3nJJCz4yCp2AATE3VscXIbITFbhoCYbmcs2hZMV7uDJT_9lXcvYM1Vsk/s72-c/sc5.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-4021981949575759564</id><published>2017-07-01T20:45:00.002-07:00</published><updated>2017-07-21T04:47:11.452-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="add rate the app"/><category scheme="http://www.blogger.com/atom/ns#" term="other apps by me"/><category scheme="http://www.blogger.com/atom/ns#" term="rate the app"/><category scheme="http://www.blogger.com/atom/ns#" term="send feedback"/><title type='text'>Ratings and feedbacks</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Once your android project is at the finishing stage, you need to add the following extra features to your app.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Rate the app&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Because rates drive app download &lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Other apps by you&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;free advertisement for your apps &lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Send feedback&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;you need them to remove bugs and improve the app &lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;/ol&gt;
Well, I personally feel that the pop up screens which ask the user to rate the app, is not a good idea. People may get irritated by this.&lt;br /&gt;
&lt;br /&gt;
But to provide the first one, you need to know the playstore page of your app. How do you get the page if you have not yet published the page?&lt;br /&gt;
&lt;br /&gt;
Well, the app page always looks like this&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;https://play.google.com/store/apps/details?id&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;=your_app_package_name&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;the last part is your package name of the app.&lt;br /&gt;
&lt;br /&gt;
And to take the user to all apps by you, you need to use a url like this&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;https://play.google.com/store/apps/developer?id=yourdevelopername&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;So these two settled, let us write our xml and code&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #bc7a00;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;menu&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
    
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:title=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Rate the app&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/rateapp&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:title=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Our other apps&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/otherapps&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:title=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Send Feedback&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/feedback&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;


&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/menu&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Of course you will fill in the other menu items of your app.&lt;br /&gt;
&lt;br /&gt;
In the onOptionsItemSelected method, add code for these three options.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onOptionsItemSelected&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;MenuItem item&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #408080; font-style: italic;&quot;&gt;// Handle navigation view item clicks here.&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; id &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; item&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getItemId&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;rateapp&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            startPlayStore&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;RATE_APP&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;otherapps&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            startPlayStore&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;OTHER_APPS&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;feedback&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            startMailFeedback&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
 &lt;span style=&quot;color: #408080; font-style: italic;&quot;&gt;/* rest of the code*/&lt;/span&gt; 
        
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Now we need to write code for viewing playstore in external browser and we also need to write code to start mail program for feedback.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;startPlayStore&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; code&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        String url &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;code&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;RATE_APP&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
             url&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;https://play.google.com/store/apps/details?id=your_app_package_name&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;code &lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt; OTHER_APPS &lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
              url &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;https://play.google.com/store/apps/developer?id=your_developer_name&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
        Intent intent &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt;  Intent&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;ACTION_VIEW&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;Uri&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;parse&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;url&lt;span style=&quot;color: #666666;&quot;&gt;));&lt;/span&gt;
        startActivity&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;intent&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;

    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;startMailFeedback&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        Intent intent &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt;  Intent&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;ACTION_SEND&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setData&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Uri&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;parse&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;mailto:&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;));&lt;/span&gt;
        intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setType&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;text/plain&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;putExtra&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;EXTRA_EMAIL&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; String&lt;span style=&quot;color: #666666;&quot;&gt;[]{&lt;/span&gt;DEV_MAIL_ID&lt;span style=&quot;color: #666666;&quot;&gt;});&lt;/span&gt;
        intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;putExtra&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Intent&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;EXTRA_SUBJECT&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Feedback on &quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;+&lt;/span&gt;getResources&lt;span style=&quot;color: #666666;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getString&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;app_name&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;));&lt;/span&gt;
        startActivity&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;intent&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Please fill in the values for your_app_package_name (which is of the format com.abcd.something - which is present in first line of all your activities :) )&amp;nbsp; and your_developer_name. And also provide your mail id in place of DEV_MAIL_ID&lt;br /&gt;
&lt;br /&gt;
The first method shows your app in playstore. Second method takes you to email program - usually gmail with &lt;b&gt;to&lt;/b&gt; as your mail id .&lt;br /&gt;
&lt;br /&gt;
That&#39;s all. &lt;br /&gt;
&lt;br /&gt;
And you are ready to get some ratings and feedbacks.&lt;br /&gt;
&lt;br /&gt;
P.S. : I was wrong earlier. I had omitted details? from the url. I realized it hard way after publishing my app with wrong app link. I am sorry if I have caused any kind of problems to any of readers.&amp;nbsp; &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/4021981949575759564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/07/ratings-and-feedbacks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4021981949575759564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4021981949575759564'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/07/ratings-and-feedbacks.html' title='Ratings and feedbacks'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-6883481995193858553</id><published>2017-07-01T19:49:00.000-07:00</published><updated>2017-07-01T19:49:20.359-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spinners"/><title type='text'>Using spinners in android </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Spinner in android is a view which shows you a drop down menu and lets you select one of the items.&lt;br /&gt;
&lt;br /&gt;
Let us see how to use a spinner in your android program.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:app=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:tools=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;app:layout_behavior=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@string/appbar_scrolling_view_behavior&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;tools:context=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;com.hegdeapps.myapplication.MainActivity&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;tools:showIn=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@layout/activity_main&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;select currency&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;Spinner&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/spinner&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;150dp&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;40dp&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginBottom=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginLeft=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginRight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginTop=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
         &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Next you need to specify what elements should the drop down menu should display. For that you can use an adapter like the one used for listview.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        /********other code******/
        Spinner sp &lt;span style=&quot;color: #333333;&quot;&gt;=(&lt;/span&gt;Spinner&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;spinner&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;final&lt;/span&gt; String arr&lt;span style=&quot;color: #333333;&quot;&gt;[]&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; String&lt;span style=&quot;color: #333333;&quot;&gt;[]{&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Rupee&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;US Dollar&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Euro&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;};&lt;/span&gt;/*values for drop down*/
        ArrayAdapter adapter &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; ArrayAdapter&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;&lt;/span&gt;String&lt;span style=&quot;color: #333333;&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;android&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;R&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;simple_spinner_item&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;arr&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        sp&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;setAdapter&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt; adapter&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        sp&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;setOnItemSelectedListener&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; AdapterView&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;OnItemSelectedListener&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onItemSelected&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;AdapterView&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;?&amp;gt;&lt;/span&gt; parent&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; View view&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; position&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;long&lt;/span&gt; id&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
                Snackbar&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;make&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;view&lt;span style=&quot;color: #333333;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;You selected &quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;+&lt;/span&gt;arr&lt;span style=&quot;color: #333333;&quot;&gt;[&lt;/span&gt;position&lt;span style=&quot;color: #333333;&quot;&gt;],&lt;/span&gt;Snackbar&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;LENGTH_LONG&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
            &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;

            &lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onNothingSelected&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;AdapterView&lt;span style=&quot;color: #333333;&quot;&gt;&amp;lt;?&amp;gt;&lt;/span&gt; parent&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;

            &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;});&lt;/span&gt;

    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
What happens when we select one of the items of the spinner? To specify that, you need to use &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;i&gt;onItemSelectedListener &lt;/i&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;as shown above.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOrxxWVHHXxJI68ImUXeYl2kVIytJKpj0GQfrxDjskqgo2qlqcfCJFKce0FzGm8-OZdibX8YDxhUKKQm5KPHhJWrhZ7V10JR3jCVDDNmZktA-2zOpQb8fcObQkyVKHI0NYRb7XW5oaa-w/s1600/spin1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOrxxWVHHXxJI68ImUXeYl2kVIytJKpj0GQfrxDjskqgo2qlqcfCJFKce0FzGm8-OZdibX8YDxhUKKQm5KPHhJWrhZ7V10JR3jCVDDNmZktA-2zOpQb8fcObQkyVKHI0NYRb7XW5oaa-w/s320/spin1.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Let us look at another example. First we will see the layout file with spinner in it.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #557799;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:app=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;xmlns:tools=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_margin=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;20dp&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:gravity=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;center&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;android:padding=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;20dp&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;app:layout_behavior=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@string/appbar_scrolling_view_behavior&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #0000cc;&quot;&gt;tools:context=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;com.hegdeapps.myapplication.MainActivity&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Length of square:&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:textSize=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;18sp&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;EditText&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/len&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:ems=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;10&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:inputType=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;number&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_weight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;1&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Select:&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:textSize=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;18sp&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;Spinner&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/spinner&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;150dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;40dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginBottom=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginLeft=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginRight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_marginTop=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_weight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;1&quot;&lt;/span&gt;
            &lt;i&gt;&lt;b&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;android:entries=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@array/type&quot;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;Button&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/button&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;

        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Calculate&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #0000cc;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/textView4&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_weight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;1&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;Answer is&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:textSize=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;18sp&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;@+id/ans&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:layout_weight=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;1&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot; &quot;&lt;/span&gt;
            &lt;span style=&quot;color: #0000cc;&quot;&gt;android:textSize=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;18sp&quot;&lt;/span&gt; &lt;span style=&quot;color: #007700;&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
In this example, we are using a spinner to select length, perimeter or area of a square. But we will not use an adapter. Instead we specify the values in xml as&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;android:entries = &quot;@array/type&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
where this type is a string array specified in an xml file in values folder, say strings.xml&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;resources&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;string&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;name=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;app_name&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;My Application&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;string&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;name=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;action_settings&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;Settings&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;string-array&lt;/span&gt; &lt;span style=&quot;color: #0000cc;&quot;&gt;name=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700;&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;item&amp;gt;&lt;/span&gt;length&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;item&amp;gt;&lt;/span&gt;perimeter&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;item&amp;gt;&lt;/span&gt;area&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/string-array&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007700;&quot;&gt;&amp;lt;/resources&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
So this string array type is used for populating the spinner instead of using java code.&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Spinner  has a method getItemSelected(), which we shall use. Please remember  that the method returns an object, so we have to type cast it.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #bb0066; font-weight: bold;&quot;&gt;MainActivity&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;extends&lt;/span&gt; AppCompatActivity &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;

    &lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;Bundle savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;super&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        setContentView&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;content_main&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        Spinner sp &lt;span style=&quot;color: #333333;&quot;&gt;=(&lt;/span&gt;Spinner&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;spinner&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        EditText etLen &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;EditText&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        Button btnCalculate &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;Button&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        btnCalculate&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;new&lt;/span&gt; View&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;OnClickListener&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: #555555; font-weight: bold;&quot;&gt;@Override&lt;/span&gt;
            &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;onClick&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;View v&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
                calculate&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
            &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;});&lt;/span&gt;

    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;

    &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #0066bb; font-weight: bold;&quot;&gt;calculate&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;{&lt;/span&gt;
        Spinner sp &lt;span style=&quot;color: #333333;&quot;&gt;=(&lt;/span&gt;Spinner&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;spinner&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        EditText etLen &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;EditText&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        String str &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;String&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt;sp&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getSelectedItem&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
        String stLen &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; etLen&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;getText&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; len &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; Integer&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;valueOf&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;stLen&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #333399; font-weight: bold;&quot;&gt;int&lt;/span&gt; ans&lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt;len&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;str&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;length&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;)){&lt;/span&gt;
            ans &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; len&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;str&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;perimeter&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;)){&lt;/span&gt;
            ans &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd; font-weight: bold;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;len&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #008800; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;str&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;equals&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0;&quot;&gt;&quot;area&quot;&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;)){&lt;/span&gt;
            ans &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; len&lt;span style=&quot;color: #333333;&quot;&gt;*&lt;/span&gt;len&lt;span style=&quot;color: #333333;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
        TextView tvAns &lt;span style=&quot;color: #333333;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;TextView&lt;span style=&quot;color: #333333;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;ans&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;);&lt;/span&gt;
        tvAns&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;setText&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;String&lt;span style=&quot;color: #333333;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000cc;&quot;&gt;valueOf&lt;/span&gt;&lt;span style=&quot;color: #333333;&quot;&gt;(&lt;/span&gt;ans&lt;span style=&quot;color: #333333;&quot;&gt;));&lt;/span&gt;
    &lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #333333;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
As we can see, we are using the getSelectedItem() to extract value from spinner and using it in calculation. Also not that we are not using any kind of adapter for the spinner.&lt;br /&gt;
&lt;br /&gt;
Here is the output of the program.&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGajPRZGGO2z3Y_aRGCuLwYLGz_oVKgKWXmlGs9q8fPQbyOMlf34AUi1iBN7TckCgLgZfah5bKK5RRgO1GFsfYYNd_wIWqFqcxfzaqQB4t-H0pDzci34tmnrLZ26AFWoJ_OpX8g9QOEms/s1600/spin2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGajPRZGGO2z3Y_aRGCuLwYLGz_oVKgKWXmlGs9q8fPQbyOMlf34AUi1iBN7TckCgLgZfah5bKK5RRgO1GFsfYYNd_wIWqFqcxfzaqQB4t-H0pDzci34tmnrLZ26AFWoJ_OpX8g9QOEms/s320/spin2.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4aw6E504G2p_UpO3IabLuvZE7aGtordugW9V8hWZQz5amB8GkIDY9oGdEK-Dc97afjXdrOAF_VgEB-jzckqIrQKf3so_iK0mmfL9bBsyx5vl3z0_EtqoCjyoGDvJosElFJ5GEj31At90/s1600/spin3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4aw6E504G2p_UpO3IabLuvZE7aGtordugW9V8hWZQz5amB8GkIDY9oGdEK-Dc97afjXdrOAF_VgEB-jzckqIrQKf3so_iK0mmfL9bBsyx5vl3z0_EtqoCjyoGDvJosElFJ5GEj31At90/s320/spin3.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;/td&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
You can also specify whether the spinner shows values as a dropdown or a dialog using this xml attribute&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; android:spinnerMode =dialog&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;android:spinnerMode =dropdown&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/6883481995193858553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/07/using-spinners-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/6883481995193858553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/6883481995193858553'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/07/using-spinners-in-android.html' title='Using spinners in android '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOrxxWVHHXxJI68ImUXeYl2kVIytJKpj0GQfrxDjskqgo2qlqcfCJFKce0FzGm8-OZdibX8YDxhUKKQm5KPHhJWrhZ7V10JR3jCVDDNmZktA-2zOpQb8fcObQkyVKHI0NYRb7XW5oaa-w/s72-c/spin1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-5292998801356844990</id><published>2017-06-17T23:55:00.000-07:00</published><updated>2017-06-17T23:55:40.325-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="home navigation with toolbar"/><category scheme="http://www.blogger.com/atom/ns#" term="support actionbar"/><category scheme="http://www.blogger.com/atom/ns#" term="toolbar"/><title type='text'>Actionbar and toolbar using support library</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Action bar has been our friend since a long time. But it has its own drawbacks. You can not change its color, or size or appearance of its elements.&lt;br /&gt;
&lt;br /&gt;
So came toolbar in android Lollipop. The beauty of this is, you add a toolbar like any other item in the layout xml file, set its color, size, position. Then add a few lines of code to make it an action bar.&lt;br /&gt;
&lt;br /&gt;
So let us dive straight into coding.&lt;br /&gt;
&lt;br /&gt;
I am using support library for toolbar and also appcompat activity. If you do not want to bother about devices with older versions than 5.0, you can straight use toolbar.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1ck0v990wkFrkmPrSkBTAgoQ_xNaXZpNjHLNX82vylNmvTrQyhlFfouJ4VUGBR_WeiFRP70iIWi0piWYibpveunHadBD7ux3PgMBsczR1S-AFncK0KB5sABFivBhBIieaYgisQnk5pk0/s1600/toolbarcreation.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;658&quot; data-original-width=&quot;1079&quot; height=&quot;390&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1ck0v990wkFrkmPrSkBTAgoQ_xNaXZpNjHLNX82vylNmvTrQyhlFfouJ4VUGBR_WeiFRP70iIWi0piWYibpveunHadBD7ux3PgMBsczR1S-AFncK0KB5sABFivBhBIieaYgisQnk5pk0/s640/toolbarcreation.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can find toolbar in appcompat option in Android studio design view of your xml file.&lt;br /&gt;
&lt;br /&gt;
So you insert that toolbar in the layout xml file. &lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #bc7a00;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #7d9029;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;vertical&quot;&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;   android:layout_margin=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;10dp&quot;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;android.support.v7.widget.Toolbar&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/toolbar2&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:background=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/colorPrimary&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:minHeight=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/actionBarSize&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:theme=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/actionBarTheme&quot;&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you can notice that it already has background as colorPrimary. Next let us set this toolbar as actiobar writing some code in onCreate() function of our activity.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;Toolbar toolbar &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Toolbar&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;toolbar&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;toolbar&lt;span style=&quot;color: #666666;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;            
            setSupportActionBar&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;toolbar&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;getSupportActionBar().setTitle(&quot;My activity&quot;); &amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Now this is how our output screen looks like &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGUfyeTU8uFRsn9O5GEWcnc1W-vYA1PAnJhrcqTNHYGk0Tu1pcA1z_Q20J9y4qBRlXhetmZ_BmgTMc5kmSU6KmeHBNGb21SPDoZJPxTZhe3fvDJ_MDLmyozWQCaagI2KtWstOWBuB9L1M/s1600/NoTitle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGUfyeTU8uFRsn9O5GEWcnc1W-vYA1PAnJhrcqTNHYGk0Tu1pcA1z_Q20J9y4qBRlXhetmZ_BmgTMc5kmSU6KmeHBNGb21SPDoZJPxTZhe3fvDJ_MDLmyozWQCaagI2KtWstOWBuB9L1M/s200/NoTitle.png&quot; width=&quot;120&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
What went wrong? Why is the actionbar cropped at left and right ends? And where is the title?&lt;br /&gt;
&lt;br /&gt;
The layout_margin=&quot;10dp&quot; causes even the actionbar to have a margin. Remove that line from parent linearlayout.&lt;br /&gt;
&lt;br /&gt;
Actionbar title will not be set unless we mention it before setting toolbar as action bar. We shall correct both now.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #bc7a00;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #7d9029;&quot;&gt;android:orientation=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;vertical&quot;&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt; &lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;android.support.v7.widget.Toolbar&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/toolbar2&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:background=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/colorPrimary&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:minHeight=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/actionBarSize&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:theme=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/actionBarTheme&quot;&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;Toolbar toolbar &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Toolbar&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;toolbar&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;toolbar&lt;span style=&quot;color: #666666;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            toolbar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setTitle&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;your title&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            setSupportActionBar&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;toolbar&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;           
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
After these two corrections, our action bar is ready like this.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnveBdRPvRLsA0CPc3wjZ3aKUoEyW1O4tqtBHqWjxpYOXK4UEjsUo423PqUuTVaUNddRbept-WxDWrYtFM7Je4uNN2Q6vxU-HJrmtt3L09GKcVc8xD3MIiLqIiPZaS8KEGxWUjn1M4a84/s1600/withTitle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnveBdRPvRLsA0CPc3wjZ3aKUoEyW1O4tqtBHqWjxpYOXK4UEjsUo423PqUuTVaUNddRbept-WxDWrYtFM7Je4uNN2Q6vxU-HJrmtt3L09GKcVc8xD3MIiLqIiPZaS8KEGxWUjn1M4a84/s200/withTitle.png&quot; width=&quot;120&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9S8Zc-aJKAtyMDGA6XRJPNtnSM0nyQxaZvFtSJRHBlnA6bdBFwwhI8xo0sU6Facwom1fX0v9DZ9Y1sQtLdppvRJYfOxWzZdrG0hVeDXquCUuROiX8SSEMNXAVURsfOjXL_lUVqwiogWw/s1600/withTitle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9S8Zc-aJKAtyMDGA6XRJPNtnSM0nyQxaZvFtSJRHBlnA6bdBFwwhI8xo0sU6Facwom1fX0v9DZ9Y1sQtLdppvRJYfOxWzZdrG0hVeDXquCUuROiX8SSEMNXAVURsfOjXL_lUVqwiogWw/s200/withTitle.png&quot; width=&quot;120&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
But if you have a theme such as &lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: black; font-family: &#39;DejaVu Sans Mono&#39;; font-size: 9.0pt;&quot;&gt;&lt;span style=&quot;background-color: #e4e4ff; color: green; font-weight: bold;&quot;&gt;Theme.AppCompat.Light.NoActionBar &lt;/span&gt;&lt;/pre&gt;
then the actionbar title will be in black. To have white text but still using them light, we need to modify the toolbar like this.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;android.support.v7.widget.Toolbar&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/toolbar2&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:background=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/colorPrimary&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:minHeight=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/actionBarSize&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:theme=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;?attr/actionBarTheme&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;app:theme=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;app:popupTheme=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@style/ThemeOverlay.AppCompat.Light&quot;&lt;/span&gt;
          &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Next we need to add home navigation to actionbar. That is done using changes in java file as well as androidmanifest.xml file.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;Toolbar toolbar &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Toolbar&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;toolbar&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;toolbar&lt;span style=&quot;color: #666666;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            toolbar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setTitle&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;your title&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            setSupportActionBar&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;toolbar&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            ActionBar actionBar &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; getSupportActionBar&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
   &lt;b&gt;         actionBar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setDisplayShowHomeEnabled&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;true&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            actionBar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setDisplayHomeAsUpEnabled&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;true&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;&lt;/b&gt;
            actionBar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setDisplayShowTitleEnabled&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            actionBar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setHomeButtonEnabled&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
And in manifest file - androidmanifest.xml add these lines to your activity&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;activity&lt;/span&gt; 
&lt;span style=&quot;color: #7d9029;&quot;&gt;android:name=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;.youractivity&quot;&lt;/span&gt; 
         &lt;span style=&quot;color: #7d9029;&quot;&gt;android:parentActivityName=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;.yourhomeactivity&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
             &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;meta-data&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:name=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;android.support.PARENT_ACTIVITY&quot;&lt;/span&gt;
            &lt;span style=&quot;color: #7d9029;&quot;&gt;android:value=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;.yourhomeactivity&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/meta-data&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/activity&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
parentActivityName is used for mentioning home activity. But for sdks less than 4.0, we need to provide the metadata as shown above.&lt;br /&gt;
&lt;br /&gt;
OK. Now we have a pretty actionbar plus home navigation. Now how about some menu options?&lt;br /&gt;
&lt;br /&gt;
You can add menu options in two different ways. a) Add buttons to toolbar. b) use onCreateOptions menu. Let us see the second option.&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;   &lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onCreateOptionsMenu&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Menu menu&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        MenuInflater inflater &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; getMenuInflater&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        inflater&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;inflate&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;menu&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;mymenu&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;menu&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onOptionsItemSelected&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;MenuItem item&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; id &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; item&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getItemId&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            TextView tv &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; TextView&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            tv&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setLayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;              &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; LinearLayoutCompat&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;LayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;ViewGroup&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;LayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;
                    ViewGroup&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;LayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;WRAP_CONTENT&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;));&lt;/span&gt;
            tv&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setText&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Hello world&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            LinearLayout linearLayout &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;LinearLayout&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;linlayout&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            linearLayout&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;addView&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;tv&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt;  &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt; &lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
 &lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGJIgDFAm0QAM9lK5M7OVdOFnq_oempCzT-VYEYACd2EwvW1ZHW-_N4rsev235HYVBcSIE7kQ5fRZmHZGM-MeSCK7zCUNLzb71tz7IdIG9St5G5HLzSDyk1umMJFGQ8l_zQE2PNKQ0Z9s/s1600/printhello.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1280&quot; data-original-width=&quot;768&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGJIgDFAm0QAM9lK5M7OVdOFnq_oempCzT-VYEYACd2EwvW1ZHW-_N4rsev235HYVBcSIE7kQ5fRZmHZGM-MeSCK7zCUNLzb71tz7IdIG9St5G5HLzSDyk1umMJFGQ8l_zQE2PNKQ0Z9s/s200/printhello.png&quot; width=&quot;120&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
printhello is a dummy options menu entry which will print helloworld in a textview by creating textview dynamically.&lt;br /&gt;
&lt;br /&gt;
First we use createOptionsMenu to inflate the options menu defined by menu file mymenu.xml in /res/menu folder&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #bc7a00;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;menu&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #7d9029;&quot;&gt;xmlns:app=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:title=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;printHello&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #7d9029;&quot;&gt;android:id=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/print&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #7d9029;&quot;&gt;app:showAsAction=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;ifRoom&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/menu&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Next in onOptionsItemSelected we print helloworld on textview which we create and add to linearlayout.&lt;br /&gt;
&lt;br /&gt;
But now a strange thing happens. The home button does not work. So home navigation is not present.&lt;br /&gt;
&lt;br /&gt;
There are two ways of overcoming this.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Do not return true from onOptionsItemSelected&amp;nbsp;&lt;/li&gt;
&lt;ul&gt;&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onOptionsItemSelected&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;MenuItem item&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; id &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; item&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getItemId&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            TextView tv &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; TextView&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            tv&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setLayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;

               &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; LinearLayoutCompat&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;LayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;ViewGroup&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;LayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;MATCH_PARENT&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;
                    ViewGroup&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;LayoutParams&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;WRAP_CONTENT&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;));&lt;/span&gt;
            tv&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setText&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Hello world&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            LinearLayout linearLayout &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;LinearLayout&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;linlayout&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            linearLayout&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;addView&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;tv&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt;  &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;  
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
 
&lt;/pre&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;li&gt;Take home as a separate itemid and write code for that&lt;/li&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;   &lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onCreateOptionsMenu&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Menu menu&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        MenuInflater inflater &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; getMenuInflater&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        inflater&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;inflate&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;menu&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;mymenu&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;menu&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onOptionsItemSelected&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;MenuItem item&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; id &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; item&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getItemId&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            /*write your code*/
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt;  &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;==&lt;/span&gt;android&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;R&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;home&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt;
            NavUtils&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;navigateUpFromSameTask&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
 &lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;That&#39;s it. Now you are well equipped to toolbar as actionbar to any activity in your android app.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/5292998801356844990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/06/actionbar-and-toolbar-using-support.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/5292998801356844990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/5292998801356844990'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/06/actionbar-and-toolbar-using-support.html' title='Actionbar and toolbar using support library'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1ck0v990wkFrkmPrSkBTAgoQ_xNaXZpNjHLNX82vylNmvTrQyhlFfouJ4VUGBR_WeiFRP70iIWi0piWYibpveunHadBD7ux3PgMBsczR1S-AFncK0KB5sABFivBhBIieaYgisQnk5pk0/s72-c/toolbarcreation.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-420345168861471837</id><published>2017-03-13T05:30:00.000-07:00</published><updated>2017-03-13T05:30:47.181-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DatePicker"/><title type='text'>DatePickers in Android</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
DatePicker is a view which lets the user select a date showing a calendar or 3 spinners for dd, mm and yy.&lt;br /&gt;
&lt;br /&gt;
Let us see how to use this.&lt;span id=&quot;goog_492976425&quot;&gt;&lt;/span&gt; &lt;span id=&quot;goog_492976426&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Easy Method:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
To use a DatePicker you can use DatePickerDialog. This can be created and shown programmatically too.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Bundle b&lt;span style=&quot;color: #666666;&quot;&gt;){&lt;/span&gt; 
&lt;span style=&quot;color: #408080; font-style: italic;&quot;&gt;/*********/&lt;/span&gt;
Button btn &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Button&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;btn&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
 btn&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; View&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;OnClickListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onClick&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;View v&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
                showPickerDialog&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
            &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;});&lt;/span&gt;
&lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;

 &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;showPickerDialog&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
       
        DatePickerDialog  dtPickerDlg &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;  &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; DatePickerDialog&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; 2017&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        dtPickerDialog&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
&lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
        
 
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
In our xml file, let us have a button and in the onclick listener of the button, let us display the date picker dialog - we call showPickerDialog.&lt;br /&gt;
&lt;br /&gt;
In showPickerDialog,&amp;nbsp; we are using a random date to initialize. &lt;br /&gt;
&lt;br /&gt;
The first&amp;nbsp; parameter is the context. Second parameter is the class which implements the interface OnDateSetListener. Next three parameters are year, month (Jan is 0) and day of month. &lt;br /&gt;
&lt;br /&gt;
Let us make our activity implement this interface&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;SomeActivity&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;extends&lt;/span&gt; AppCompatActivity &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;implements&lt;/span&gt; DatePickerDialog&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;OnDateSetListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;

&lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onDateSet&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;DatePicker view&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; year&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; month&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; dayOfMonth&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        Calendar c &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getInstance&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;DAY_OF_MONTH&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;dayOfMonth&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;month&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;year&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        mDate &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; DateFormat&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;dd-MM-yyyy&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;c&lt;span style=&quot;color: #666666;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        TextView tvMessage &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;TextView&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;textView&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        tvMessage&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setText&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;You have selected :&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;+&lt;/span&gt;mDate&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;

    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
As we can see, we modified the class header added to the phrase &quot;implements DatePickerDialog.OnDateSetListener &quot; to it.&lt;br /&gt;
&lt;br /&gt;
The studio will prompt you to add the method onDateSet. The last 3 parameters are selected year, month and day of the Datepicker.&lt;br /&gt;
&lt;br /&gt;
In this example, I am displaying this value in a textview.&lt;br /&gt;
&lt;br /&gt;
Calendar.getInstance() will return&amp;nbsp; a calendar object with current date and time. You can modify it as shown by setting day, month and year fields.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2m03ux2EvNZE7on0fp209-p7gY_GDjCkmQV2fV81LENBQY-3Ijb9PTgsnID2x48EJ4L6YC_J-Z5eYWljVwtxLNjOGlcMcMGZKA_dcArkn7ICTrRo7kYD_ZGBZK-hysIY85VRpKjSqak/s1600/device-2017-03-13-131120.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2m03ux2EvNZE7on0fp209-p7gY_GDjCkmQV2fV81LENBQY-3Ijb9PTgsnID2x48EJ4L6YC_J-Z5eYWljVwtxLNjOGlcMcMGZKA_dcArkn7ICTrRo7kYD_ZGBZK-hysIY85VRpKjSqak/s400/device-2017-03-13-131120.png&quot; width=&quot;203&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrqcytFD6-HZY_Rct6te3ZyybYdZNqFLSYZ1ErUGfuUa0jiWRsjnqdTtWvlOMya9vWRdwZHTsYw0fbWxUnE6Hj_zTbZ4PZp4kvaztG0IDH2cqunYkk0HZfuO1xTZm4745WJy37c9j1l6U/s1600/device-2017-03-13-164531.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrqcytFD6-HZY_Rct6te3ZyybYdZNqFLSYZ1ErUGfuUa0jiWRsjnqdTtWvlOMya9vWRdwZHTsYw0fbWxUnE6Hj_zTbZ4PZp4kvaztG0IDH2cqunYkk0HZfuO1xTZm4745WJy37c9j1l6U/s400/device-2017-03-13-164531.png&quot; width=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that we initialized the dialog with 2017,10,20 and the dialog shows 2017 November 20th. So keep in mind, month number starts with 0.&amp;nbsp; &lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
There is a GOTCHA&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now let us try to display the date picker as a 3 spinners. This can be done using two lines of code&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getDatePicker&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setSpinnersShown&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;  
 dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getDatePicker&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;().&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setCalendarViewShown&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Studio gives you a warning that these methods are deprecated. But unlike other deprecated methods, these methods actually do not work in sdk 21- Lollipop onwards. So the dialog still shows calendar instead of spinners.&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Solution&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I tried various options. As far as I could find out, the only solution seems to be to use DatePicker in a normal dialog or a dialog fragment instead of a DatePickerDialog.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Let us look at that.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;final&lt;/span&gt; Dialog  dtPickerDlg &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; Dialog&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;        
       dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setContentView&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;layout&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;picker&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;     
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;final&lt;/span&gt; DatePicker picker &lt;span style=&quot;color: #666666;&quot;&gt;=(&lt;/span&gt;DatePicker&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;findViewById&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;datePicker&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        Button btnOk &lt;span style=&quot;color: #666666;&quot;&gt;=(&lt;/span&gt;Button&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;findViewById&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;okbutton&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        btnOk&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; View&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;OnClickListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onClick&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;View v&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
                dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;dismiss&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
            &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;});&lt;/span&gt;
        Calendar c &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getInstance&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; dd &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;DAY_OF_MONTH&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; mm &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; yy &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
      &lt;span style=&quot;background-color: #ea9999;&quot;&gt;  picker&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;yy&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;mm&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;dd&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: #408080; font-style: italic;&quot;&gt;//last parameter is datechangelistener&lt;/span&gt;&lt;/span&gt;
        dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        dtPickerDlg&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setOnDismissListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;new&lt;/span&gt; DialogInterface&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;OnDismissListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;()&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
            &lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onDismiss&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;DialogInterface dialog&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;

                TextView tvMessage &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;TextView&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt;findViewById&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;R&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;textView&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
                tvMessage&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;setText&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;You have selected :&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;+&lt;/span&gt;mDate&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
            &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
        &lt;span style=&quot;color: #666666;&quot;&gt;});&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Here is the layout xml file /res/layout/picker.xml&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;?&lt;/span&gt;xml version&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;1.0&quot;&lt;/span&gt; encoding&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt;LinearLayout &lt;span style=&quot;color: #a0a000;&quot;&gt;xmlns:&lt;/span&gt;android&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;orientation&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;vertical&quot;&lt;/span&gt; &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_width&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
    &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_height&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;gt;&lt;/span&gt;

    &lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt;DatePicker
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/datePicker&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_width&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_height&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
       &lt;span style=&quot;background-color: #ffd966;&quot;&gt; &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;calendarViewShown&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;false&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;datePickerMode&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;spinner&quot;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt;Button
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_width&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_height&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_gravity&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;right&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;background&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@android:color/transparent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;text&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;OK&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/okbutton&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;/&lt;/span&gt;LinearLayout&lt;span style=&quot;color: #666666;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Look at the two highlighted lines. You can set datePickerMode to spinner or calendar. Even when you set to spinner, a calendar is also shown. To avoid that, set&amp;nbsp; calendarviewshown as false.&lt;br /&gt;
&lt;br /&gt;
Now for the listeners! Funny, there is no dateset listener. Not so easily found at least.&lt;br /&gt;
&lt;br /&gt;
I tried documentation and trying to use autocomplete with setOnDateSet or addOnDateSet etc. No. They are not to be found.&lt;br /&gt;
&lt;br /&gt;
Finally the solution was found as init method. Datepicker should have an init method with initial values of dd, mm and yy and also the datesetlistener.&lt;br /&gt;
&lt;br /&gt;
Look at the pink highlighted line again.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;  picker&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;yy&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;mm&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;dd&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;&lt;span style=&quot;color: #408080; font-style: italic;&quot;&gt;//last parameter is datechangelistener&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;/pre&gt;
&lt;br /&gt;
The init method takes OnDateChangeListener as fourth parameter. By adding this as fourth parameter, your activity should implement &lt;br /&gt;
&lt;pre style=&quot;background-color: white; color: black; font-family: &#39;DejaVu Sans Mono&#39;; font-size: 9.0pt;&quot;&gt;DatePicker.&lt;span style=&quot;background-color: #e4e4ff;&quot;&gt;OnDateChangedListener&amp;nbsp; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: white; color: black; font-family: &#39;DejaVu Sans Mono&#39;; font-size: 9.0pt;&quot;&gt;&lt;span style=&quot;background-color: #e4e4ff;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
Studio adds the interface and the method like this.&lt;/div&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: blue; font-weight: bold;&quot;&gt;SomeActivity&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;extends&lt;/span&gt; AppCompatActivity &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;implements&lt;/span&gt; DatePicker&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;OnDateChangedListener&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #aa22ff;&quot;&gt;@Override&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;onDateChanged&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;DatePicker view&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; year&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; monthOfYear&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #b00040;&quot;&gt;int&lt;/span&gt; dayOfMonth&lt;span style=&quot;color: #666666;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
        Calendar c &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; Calendar&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;getInstance&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
        c&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;year&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;monthOfYear&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;dayOfMonth&lt;span style=&quot;color: #666666;&quot;&gt;);&lt;/span&gt;
        mDate &lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt; DateFormat&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;format&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;dd-MM-yyyy&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt;c&lt;span style=&quot;color: #666666;&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;();&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;} &lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
So that&#39;s it. Mission accomplished. We are able to show a date selector as a spinner.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgElU08-QfEnx_sNR-i1m_oH7bGTVsS7YF1MCvVxG1oZgzMxGMH3b3bPzagSdNpMH0qolEfWexSD6cbA7Mcc-_hwK-qGRwzgcEKpXgVgJOJzQwuSkimtkpn3irmUTBoRrdl_R7ibs0lA1o/s1600/device-2017-03-13-131023.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgElU08-QfEnx_sNR-i1m_oH7bGTVsS7YF1MCvVxG1oZgzMxGMH3b3bPzagSdNpMH0qolEfWexSD6cbA7Mcc-_hwK-qGRwzgcEKpXgVgJOJzQwuSkimtkpn3irmUTBoRrdl_R7ibs0lA1o/s400/device-2017-03-13-131023.png&quot; width=&quot;203&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You can download the complete project from &lt;a href=&quot;https://drive.google.com/file/d/0B2yEYnooo9GXSGhzZk92aEdzaVk/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/420345168861471837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/03/datepickers-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/420345168861471837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/420345168861471837'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/03/datepickers-in-android.html' title='DatePickers in Android'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-2m03ux2EvNZE7on0fp209-p7gY_GDjCkmQV2fV81LENBQY-3Ijb9PTgsnID2x48EJ4L6YC_J-Z5eYWljVwtxLNjOGlcMcMGZKA_dcArkn7ICTrRo7kYD_ZGBZK-hysIY85VRpKjSqak/s72-c/device-2017-03-13-131120.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-1547201259286430903</id><published>2017-02-23T23:01:00.001-08:00</published><updated>2017-02-23T23:02:43.607-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Floaging label"/><category scheme="http://www.blogger.com/atom/ns#" term="Hint"/><category scheme="http://www.blogger.com/atom/ns#" term="TextInputLayout"/><title type='text'>Floating Label for EditText</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Because of space constraints, it is difficult to create self explanatory forms in mobile apps. Do you write a label for each field? If yes, the labels will also take half of the space in your form.&lt;br /&gt;
&lt;br /&gt;
Hints solve the problem to some extent. If you add a hint for an EditText, when the field is blank, this hint is shown.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt;EditText
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_width&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_height&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/et1&quot;&lt;/span&gt;

        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;hint&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
So now our hint is shown in Edit Text like this&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW1KQbXWrBw6kZKTMKUGVTRSxfBKY_K9ULcrp11WhkmO72kdl_qf9UCNfZ9VXhg34cQf2WGTU24qhaIeAAouU8IUPgoBKQAOOXzWL3rPZ1RVc5SNHOcrSD9oQfDFtqgroQdSp7oEiJX5Q/s1600/Hint.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW1KQbXWrBw6kZKTMKUGVTRSxfBKY_K9ULcrp11WhkmO72kdl_qf9UCNfZ9VXhg34cQf2WGTU24qhaIeAAouU8IUPgoBKQAOOXzWL3rPZ1RVc5SNHOcrSD9oQfDFtqgroQdSp7oEiJX5Q/s320/Hint.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
But the moment you start entering value into the field, the hint vanishes.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSV-Ikf8OswhjTW1f15PM-mN_dzaHrcIWtr6sXgscxBDTguv25XPxjGKMA8EfUR90LppRxHAezL-wQMVhPrgq5toO7thaqiO4GkNUTPLF3hnKrb-ZQykJ5qnpUGaNQYrq4zoFO0AZ0Am0/s1600/NoHint.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSV-Ikf8OswhjTW1f15PM-mN_dzaHrcIWtr6sXgscxBDTguv25XPxjGKMA8EfUR90LppRxHAezL-wQMVhPrgq5toO7thaqiO4GkNUTPLF3hnKrb-ZQykJ5qnpUGaNQYrq4zoFO0AZ0Am0/s320/NoHint.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
To overcome this problem, support library comes to our rescue. It has a layout called TextInputLayout which places the hint as a floating label.&lt;br /&gt;
&lt;br /&gt;
To use this first you need to add two lines to your build.gradle file in yourapplication/app directory.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;dependencies &lt;span style=&quot;color: #666666;&quot;&gt;{&lt;/span&gt;
    compile &lt;span style=&quot;color: blue;&quot;&gt;fileTree&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #a0a000;&quot;&gt;dir:&lt;/span&gt; &lt;span style=&quot;color: #ba2121;&quot;&gt;&#39;libs&#39;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #a0a000;&quot;&gt;include:&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&#39;*.jar&#39;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;])&lt;/span&gt;

   &lt;span style=&quot;background-color: cyan;&quot;&gt; compile &lt;span style=&quot;color: #ba2121;&quot;&gt;&#39;com.android.support:appcompat-v7:25.1.1&#39;&lt;/span&gt;
    compile &lt;span style=&quot;color: #ba2121;&quot;&gt;&#39;com.android.support:design:25.1.0&#39;&lt;/span&gt;&lt;/span&gt;
     
&lt;span style=&quot;color: #666666;&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Next you should wrap your EditText in TextInputLayout as shown below. &lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;background-color: cyan;&quot;&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt;android&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;support&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;design&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;widget&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;TextInputLayout&lt;/span&gt;
       &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_width&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
       &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_height&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #666666;&quot;&gt;&amp;lt;&lt;/span&gt;EditText
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_width&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;layout_height&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;id&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@+id/et1&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #a0a000;&quot;&gt;android:&lt;/span&gt;hint&lt;span style=&quot;color: #666666;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Name&quot;/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #ba2121;&quot;&gt;   &amp;lt;/&lt;/span&gt;android&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;support&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;design&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;widget&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #7d9029;&quot;&gt;TextInputLayout&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
Aha! Now your hint acts as a label for input field. And it is always present. When field is empty, hint is shown inside the field. When you start typing, hint is shown as floating label in accent color. And after you finish typing, hint is shown as floating label in grey color.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig8n3dacOaW5ToUbMcb1DOpJSou9Ij2p-V_8zrbxK4HQlsTBYHn584Y5uYPVzhd-89HcUpQlhbDHPWS6Ejt_YDs2JhItamlFRe7JgMx6Wx6lDkRAnKNYAv9jzF6GgoPQ32TNEbOppAgxg/s1600/Screenshot_1487917065.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig8n3dacOaW5ToUbMcb1DOpJSou9Ij2p-V_8zrbxK4HQlsTBYHn584Y5uYPVzhd-89HcUpQlhbDHPWS6Ejt_YDs2JhItamlFRe7JgMx6Wx6lDkRAnKNYAv9jzF6GgoPQ32TNEbOppAgxg/s320/Screenshot_1487917065.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZGEOH-EKHTTM9IQAguEJi68NMdYy6Xvgwd0FzGNf_Dvazltw2MIHdF_3qjV7ZlyTK6FIEREnJIjEkd6WEkZkNQvjhgFFs1S62Y5aT_Aeo3fisM_gUzi1fCkOuV2FnUm-1flXnXafqGM4/s1600/Screenshot_1487917167.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZGEOH-EKHTTM9IQAguEJi68NMdYy6Xvgwd0FzGNf_Dvazltw2MIHdF_3qjV7ZlyTK6FIEREnJIjEkd6WEkZkNQvjhgFFs1S62Y5aT_Aeo3fisM_gUzi1fCkOuV2FnUm-1flXnXafqGM4/s320/Screenshot_1487917167.png&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
So you achieved all these just by using xml files (and of course support library). Happy coding!!&lt;br /&gt;
&lt;br /&gt;
You can find app folder of the application &lt;a href=&quot;https://drive.google.com/file/d/0B2yEYnooo9GXYXN4QVdTZ0FvTUE/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&amp;nbsp; &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/1547201259286430903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/02/floating-label-for-edittext.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1547201259286430903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1547201259286430903'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/02/floating-label-for-edittext.html' title='Floating Label for EditText'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW1KQbXWrBw6kZKTMKUGVTRSxfBKY_K9ULcrp11WhkmO72kdl_qf9UCNfZ9VXhg34cQf2WGTU24qhaIeAAouU8IUPgoBKQAOOXzWL3rPZ1RVc5SNHOcrSD9oQfDFtqgroQdSp7oEiJX5Q/s72-c/Hint.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-4912674342375368840</id><published>2017-02-11T18:24:00.000-08:00</published><updated>2017-02-11T18:24:22.092-08:00</updated><title type='text'>C++ Notes published</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I have published my next app - &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.cppquestions&quot; target=&quot;_blank&quot;&gt;C++ Notes&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPylTjHFJj_yt3qNkXjfrUZHWgQe9uI8ZcikXGmgfiFduk75dM0Obx6aepskYGFehMteyVRcVhxMUEz6hvHwJdZmajtDUaW0I5ZwGiwQdsTMMDGEDf6ZYKp5YQTFLfJwo3hjEilOj9oYA/s1600/Ref.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPylTjHFJj_yt3qNkXjfrUZHWgQe9uI8ZcikXGmgfiFduk75dM0Obx6aepskYGFehMteyVRcVhxMUEz6hvHwJdZmajtDUaW0I5ZwGiwQdsTMMDGEDf6ZYKp5YQTFLfJwo3hjEilOj9oYA/s400/Ref.png&quot; width=&quot;273&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The app has short notes on basic and advanced topics of C++ along with quiz and programs.&lt;br /&gt;
&lt;br /&gt;
I have tried to use material design here - may not be so successful. And have used firebase ads instead of admob. Admob has now become firebase.&lt;br /&gt;
&lt;br /&gt;
Be careful, when you add firebase ads, three extra permissions are added to the app - WAKELOCK and some c2d -permission-receive and c2d message. And users will wonder why the hell this app needs these permissions.&lt;br /&gt;
&lt;br /&gt;
So you can add these lines in your manifest file to remove these permissions.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&amp;lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; tools:node=&quot;remove&quot; /&amp;gt;
 &amp;lt;uses-permission android:name=&quot;com.google.android.c2dm.permission.RECEIVE&quot; tools:node=&quot;remove&quot; /&amp;gt;
 &amp;lt;uses-permission android:name=&quot;your.app.package.permission.C2D_MESSAGE&quot; tools:node=&quot;remove&quot; /&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
I spent quite some time on deciding about scrolling and swiping. Notes had some formatting - colors, fonts etc. So I thought I will use HTML and webview.&amp;nbsp; Questions are some what lengthy, I had to put these in a&amp;nbsp; scrollview. Webview has a scroll feature automatically.&lt;br /&gt;
&lt;br /&gt;
So when I tried to add swipe feature using ontouch listener, the behavior was erratic. Scroll would swipe the page. After lot of tinkering, I decided not to use swipe at all. Any views?&lt;br /&gt;
&lt;br /&gt;
And it would have looked good, if the continue button was visible only when the webview scrolled to the bottom. Could not do it. :(&lt;br /&gt;
&lt;br /&gt;
And I processed the html pages using Kompozer - reasonably good enough tool for HTML formatting. But even within that, code formatting was not good. So I used hilite.me site for formatting code with colors, borders etc.&lt;br /&gt;
&lt;br /&gt;
Instead of actionbar I used toolbar with support library. Support library because my minimum sdk is 11. Toolbar is OK. Not as friendly as I expected it to be. But one good thing is you can add widgets in it directly and format them as you want them to be and write on click listeners to them.&lt;br /&gt;
&lt;br /&gt;
One thing which I forgot was search feature. This is present in C app. But here since the topics were already highlighted in first page, I let it lapse.&lt;br /&gt;
&lt;br /&gt;
Download the app and give me your feedback.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/4912674342375368840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/02/c-notes-published.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4912674342375368840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4912674342375368840'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2017/02/c-notes-published.html' title='C++ Notes published'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPylTjHFJj_yt3qNkXjfrUZHWgQe9uI8ZcikXGmgfiFduk75dM0Obx6aepskYGFehMteyVRcVhxMUEz6hvHwJdZmajtDUaW0I5ZwGiwQdsTMMDGEDf6ZYKp5YQTFLfJwo3hjEilOj9oYA/s72-c/Ref.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-765300878245256348</id><published>2016-12-04T21:21:00.001-08:00</published><updated>2016-12-04T21:21:51.779-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="3d effect"/><category scheme="http://www.blogger.com/atom/ns#" term="elevation in android"/><category scheme="http://www.blogger.com/atom/ns#" term="shadows for views"/><title type='text'>Adding depth</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Android sdk 5.0 - material, has a new property called &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;elevation &lt;/span&gt;for views. Elevation gives z value for views. So views with higher elevation will cast a shadow.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Elevation can be set using xml&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;android:elevation =&quot;somevalue&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Or using code&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;viewname.setElevation(5);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Let us look at how a textview uses elevation property.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:background=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;#a3c6fa&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&lt;/span&gt;&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:elevation=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;5dp&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzS-fp5h5ja_jHUASmYVOCy_wAgkopr703sYqwyrIuJ64BfocQ9YuQzj773b9aP9nSGm7QFfqM2iuDyUf4fT6uY5uFNzM4GIp2rcn9up0eM79BFY46MtgGpH68dDYRfnViK-vLkqKUxS0/s1600/device-2016-12-05-100247.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzS-fp5h5ja_jHUASmYVOCy_wAgkopr703sYqwyrIuJ64BfocQ9YuQzj773b9aP9nSGm7QFfqM2iuDyUf4fT6uY5uFNzM4GIp2rcn9up0eM79BFY46MtgGpH68dDYRfnViK-vLkqKUxS0/s320/device-2016-12-05-100247.png&quot; width=&quot;163&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;We are setting elevation of the textview to 5dp. We are setting light blue background color for textview.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Now our hello world textview looks like this.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Pretty simple. Isn&#39;t it?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Not quite so. Because elevation property needs sdk 21 or higher. You can not tell user to buy a new phone, just so that views will have a shadow. Can you?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The solution for older phones is layer-list. A layer-list drawable places different drawables on top of each other with given offset.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;So let us write our layer-list .&lt;/span&gt;&lt;br /&gt;
shadow.xml&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: #bc7a00;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;layer-list&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;shape&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;solid&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:color=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;#a3c6fa&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/shape&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;item&lt;/span&gt;  &lt;span style=&quot;color: #7d9029;&quot;&gt;android:top=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;0dp&quot;&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:right=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;2dp&quot;&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:bottom=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;2dp&quot;&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:left=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;0dp&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;shape&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;solid&lt;/span&gt; &lt;span style=&quot;color: #7d9029;&quot;&gt;android:color=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;#8fd1f5&quot;&lt;/span&gt;
              &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;

        &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/shape&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;/layer-list&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Each&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; &amp;lt;item&amp;gt;&lt;/span&gt; in this is one layer drawable. We have two layers here. First layer is grey color rectangle. Next layer is light blue rectangle with offset of 2dp at right and bottom.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Next let us add this as background to our textview. &lt;/span&gt;&lt;br /&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;br /&gt;
&lt;div style=&quot;background: #f8f8f8; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;&quot;&gt;
&lt;pre style=&quot;line-height: 125%; margin: 0;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;&amp;lt;TextView&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_width=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:layout_height=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:background=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;@drawable/shadow&quot;&lt;/span&gt;
     
        &lt;span style=&quot;color: #7d9029;&quot;&gt;android:text=&lt;/span&gt;&lt;span style=&quot;color: #ba2121;&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;After adding this code to the app, here is how our hello world looks like&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs47482Z9uMSTHxicoumPoiKQInVQrG8jEWXiQ_UT6ZQu3qrXsAeNqICVQvWv-7W14orkWXCBzuZOZ5VrUoQqIQnpGM5C56D9CMGqEgjvdm4UWkJYUHVkL1AzAgnuJO9I0QdJxh5d3V7A/s1600/shadiw.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs47482Z9uMSTHxicoumPoiKQInVQrG8jEWXiQ_UT6ZQu3qrXsAeNqICVQvWv-7W14orkWXCBzuZOZ5VrUoQqIQnpGM5C56D9CMGqEgjvdm4UWkJYUHVkL1AzAgnuJO9I0QdJxh5d3V7A/s320/shadiw.png&quot; width=&quot;163&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Who needs to spend hours on GIMP, when we know our xml? &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/765300878245256348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/12/adding-depth.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/765300878245256348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/765300878245256348'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/12/adding-depth.html' title='Adding depth'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzS-fp5h5ja_jHUASmYVOCy_wAgkopr703sYqwyrIuJ64BfocQ9YuQzj773b9aP9nSGm7QFfqM2iuDyUf4fT6uY5uFNzM4GIp2rcn9up0eM79BFY46MtgGpH68dDYRfnViK-vLkqKUxS0/s72-c/device-2016-12-05-100247.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-7823868956359565532</id><published>2016-08-17T22:18:00.000-07:00</published><updated>2016-08-18T02:13:49.753-07:00</updated><title type='text'>Using simple html in android</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;In an app, instead of using a textview, we can use a webview. Why? Because webview is better looking. And, more importantly, we can format the text easily - specifically for long, long text. And, yes, it has an automatic scroll controls.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Now how do we display a static text in a webview?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;String str=&quot;your text here&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;webview.loadData(str,&quot;text/html&quot;,null);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;But your string should also have html tags in them. The simplest tags are html and body. So surround your string with these. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;String str=&quot;your text here&quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;String str = &quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&quot;+str+&quot;&amp;lt;/body&amp;gt;&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;webview.loadData(str,&quot;text/html&quot;,null);&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;But if you are using for formatting the text, like &lt;b&gt;bold&lt;/b&gt;, &lt;i&gt;italic&lt;/i&gt;, &lt;span style=&quot;font-family: &amp;quot;helvetica neue&amp;quot; , &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;different font&lt;/span&gt; etc. to be used for some parts of the text? How do you get that done?&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;The straight forward solution is learn html and hand code all the B &#39;s and slash B&#39;s etc. yourself.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Of course, I am kidding. There are plenty of html editors available for automating this task. Look for a editor with WYSWIG feature. And take your text, format them using tool bar buttons and get the source html code, and paste it. I am currently using Kompozer.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;OK. That task is completed. Now your webview is looking all cool and nice. But for any reason, if you want to extract plain text from this string, how do you accomplish that? You need to remove all the html tags.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Thankfully there is one line solution for this&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;String plainText = android.text.Html.fromHtml(strWithAllTags).toString();&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;This will remove all html tags from the string and give you the content.&lt;/span&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Note:  I formatted using HTML tags - but not only did my courier font did not  show correctly, where ever I used a different font, there was an extra  line in between. So if you face such problem,&amp;nbsp; you need to use  loadDataWithBaseURL as shown below&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;wv.loadDataWithBaseURL(null,&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;str&lt;/span&gt;,&quot;text/html&quot;, null,null);&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/7823868956359565532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/08/using-simple-html-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7823868956359565532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7823868956359565532'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/08/using-simple-html-in-android.html' title='Using simple html in android'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-3534006028905881474</id><published>2016-06-09T06:32:00.002-07:00</published><updated>2016-06-09T06:32:48.003-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="custom view error"/><category scheme="http://www.blogger.com/atom/ns#" term="Custom view in android"/><category scheme="http://www.blogger.com/atom/ns#" term="custom view in xml file"/><title type='text'>Adding custom view to xml</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;You wanted to write your own custom view. You wrote it extending &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;View &lt;/span&gt;class or better still &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;TextView &lt;/span&gt;or &lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;ImageView &lt;/span&gt;class. You even added this view&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt; within your activity using Java code an&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;d tested it successful&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ly. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;But adding views with Java is a lengthy process and is cumbersome. xml makes the process easier.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;So how do you add your custom view into your layout xml file?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;somelayout.xml&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; &amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;  
 &amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;  
        android:orientation=&quot;vertical&quot;  
        android:layout_width=&quot;match_parent&quot;  
        android:layout_height=&quot;match_parent&quot;&amp;gt;  
 &amp;lt;!--  Other Views --&amp;gt;  
     &amp;lt;com.some.name.CustomView  
       android:layout_width=&quot;wrap_content&quot;  
       android:layout_height=&quot;wrap_content&quot;  
       android:id=&quot;@+id/cell1&quot;/&amp;gt;  
 &amp;lt;!--  Other Views --&amp;gt;  
 &amp;lt;/LinearLayout&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
OK, &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;this is how you add your view in the xml file. Please note the fully qualified class name of custom view - including the package na&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;me.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;After this your activity&amp;nbsp;&lt;/span&gt; some times &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;gives an&lt;/span&gt; error - error inflating the file. Why?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Two things you need to keep in mind.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;You need at least two constructors for your customview class.&amp;nbsp; One with &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Context &lt;/span&gt;&lt;/span&gt;as parameter. And second with &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Context &lt;/span&gt;and &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;AttributeSet &lt;/span&gt;as parameters. You need &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;both the constructors even if you do not use any custom attributes for your class&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Both these constructors should be &lt;b&gt;public&lt;/b&gt;. &lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;e.g.&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;pre style=&quot;background: #f0f0f0; border: 1px dashed #cccccc; color: black; font-family: &amp;quot;arial&amp;quot;; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;  class MyCustomView extends ImageView  
 {  
 /**some code here ****/  
 public MyCustomView(Context ctx)  
 {  
  /* your code **/  
 }  
 public MyCustomView(Context ctx, AttributeSet attrs)  
 {  
 /** code **/  
 }  }
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now your View will be available in the activity.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Note : My experience has been, the more code you leave to the library, better for you. Specifically measurements and layouts.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/3534006028905881474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/06/adding-custom-view-to-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/3534006028905881474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/3534006028905881474'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/06/adding-custom-view-to-xml.html' title='Adding custom view to xml'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-5973047290446379999</id><published>2016-05-02T07:45:00.000-07:00</published><updated>2016-05-02T07:45:14.987-07:00</updated><title type='text'>An app and a story</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
An app and a story&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I am not writing anything about coding tip here. But telling you how my app Shataka came into existence.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Few years back, I had started an app, whose idea was to find all combinations of numbers to get the required sum. Something like,&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;90 = 10*9&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; = 45*2&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; = 200 -110&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;etc.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Then the app was killed because my computer was. I did not have a single line of code remaining.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;That was metamorphasized into this unique app Shataka. As far as I know, in android market there are not many number games for adults. There are few me-too versions of 2048 and few apps which ask you to type what is 10 +2 etc.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;But in this app, the sum was to be 100, for rows and columns. And typing the numbers is clumsy and guessing 9 numbers to fill in 3 by 3 grid for this is too time consuming. So what if I provide the numbers after shuffling them?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Yes. I provide 9 numbers which if arranged in an order, make a grid with sum of each row as 100 and sum of each column as 100.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;e.g.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;81 4 15&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;10 73 17&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;9 23 68&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;So I generate one set of numbers - which will be one puzzle. I generate a second set, third set. How many sets should I store in the app? It should be possible to generate numbers randomly.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Generate one number randomly. Then find combinations for next 2 numbers etc. e.g. if let us say number is x1 is 10, then x2 can be 60 and x3 can be 30. Now 10+x4+x7 = 100 and 60+x5+x8 should be 100 and 30+x6+x9 should be 100. And also x4+x5+x6=100 and so on.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Few random numbers, few equations and some iterations, our puzzle set is ready. Give an empty grid, below which give 9 numbers and ask the user to fill the grid.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;What I realized is, for the beginner, it is difficult to select numbers. Then I thought of hints. Providing hints for games is too complex. At least for this game it was.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;If not hint, how about giving them partial solution. For the easy level, fill 3 cells of the grid, so that user needs to add only 6 numbers. That will be better and that will also make the game familiar.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRd_ieqGulqEoBHRSW869pU1ai_Yv2bzWDK0ROygrLhyphenhyphenNemhQPj8H8qj1rc89d_y4wf2RZ5DELxtfuXeESkuoRyuVV9F6v4dSdDPcFPxRmr-ifqTXIVZOXL0cGQv0Pm2V8hi8F4jEGVWI/s1600/Screenshot_2016-05-02-20-00-54.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRd_ieqGulqEoBHRSW869pU1ai_Yv2bzWDK0ROygrLhyphenhyphenNemhQPj8H8qj1rc89d_y4wf2RZ5DELxtfuXeESkuoRyuVV9F6v4dSdDPcFPxRmr-ifqTXIVZOXL0cGQv0Pm2V8hi8F4jEGVWI/s400/Screenshot_2016-05-02-20-00-54.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;That is what you see in Level 1 of the game. Level 2, gives the user 2 solved cells, level 3 gives 1 solved cell. And of course there are no solved cells in level 4.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Is that all? Will this game have only 4 levels? That will be too ridiculous. What if we add an extra number, which is not part of the solution to the game like this&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie9hWxSi3P2SkCjJqcOFzzEzskxxAadEj7zDlovShFfZSeKLl1EMJa58ur8Z6Jvn5NsdWfeuNCv4OHi1Z5ZLTcm0oG8ouKWyTUGdx8z06ZuQP_O0d9ooWqclbXL-cfrEPRtkBWnA3BdlI/s1600/Screenshot_2016-05-02-20-00-32.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie9hWxSi3P2SkCjJqcOFzzEzskxxAadEj7zDlovShFfZSeKLl1EMJa58ur8Z6Jvn5NsdWfeuNCv4OHi1Z5ZLTcm0oG8ouKWyTUGdx8z06ZuQP_O0d9ooWqclbXL-cfrEPRtkBWnA3BdlI/s400/Screenshot_2016-05-02-20-00-32.png&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;We have 10 n&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;umber&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;s given instead of 9. So makes the game little&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt; &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;bit more challenging.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;So that provided us level 5 and &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;6(with 2 extra numbers) and 7(3 extra numbers).&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;And with these features&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;, I pub&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;lishe&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;d the app&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;But &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;the game will become boring &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;if it has only 7 levels. So in next version, I tho&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ught of not &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;just&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt; shataka, but sahasrak&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;a - shataka in Sanskrit is 100 and sahasraka is 1000. So provide th&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ree&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt; numbers to add up to 1000.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;And what about a sum of 77 or 92 of 66 that is some random 2 digit number. That &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;is another set of levels&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi35vY4ReTYODZ2ZCetdeSrhwZDwHlyi6Q4f8ySfNGmFPK9DnBVXyIEsCUoRXkMI8Y8Sg6j12c0jBuzz5XVS9rPKBvM0IRXVl1lRXcE7EAD4JfDmw8yyA0z-cu-oATyw6CYas3D64c7MVM/s1600/Screenshot_2016-05-02-20-11-59%255B1%255D.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi35vY4ReTYODZ2ZCetdeSrhwZDwHlyi6Q4f8ySfNGmFPK9DnBVXyIEsCUoRXkMI8Y8Sg6j12c0jBuzz5XVS9rPKBvM0IRXVl1lRXcE7EAD4JfDmw8yyA0z-cu-oATyw6CYas3D64c7MVM/s320/Screenshot_2016-05-02-20-11-59%255B1%255D.png&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;Why is ther&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;e no screen shot of s&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;ahasraka - because &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;I have&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt; not yet reached that level :)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;So dear &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;readers, what is the &lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;next feature you wa&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;nt me to add t&lt;span style=&quot;font-family: &amp;quot;verdana&amp;quot; , sans-serif;&quot;&gt;o this awesome game?&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/5973047290446379999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/05/an-app-and-story.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/5973047290446379999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/5973047290446379999'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/05/an-app-and-story.html' title='An app and a story'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRd_ieqGulqEoBHRSW869pU1ai_Yv2bzWDK0ROygrLhyphenhyphenNemhQPj8H8qj1rc89d_y4wf2RZ5DELxtfuXeESkuoRyuVV9F6v4dSdDPcFPxRmr-ifqTXIVZOXL0cGQv0Pm2V8hi8F4jEGVWI/s72-c/Screenshot_2016-05-02-20-00-54.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-7367681102164838351</id><published>2016-03-21T09:18:00.000-07:00</published><updated>2016-03-21T09:18:01.293-07:00</updated><title type='text'>Shataka updated</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
A completely original math game &quot;Shataka&quot; was published in Oct&#39; 2014. The apps age faster than us:) So the design and UI were looking quite old. Hence an update has been published on March 14th&lt;br /&gt;
&lt;br /&gt;
Here are the new features&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKL7nu_Bd67zQooFpx3DZJTSRJL4B7JIaQO55rZTqVu7o8fnlaaCY-JY2wv_8mDvbSXujIR5opvgK7mdzDJf-HO2JrJddsPLNuPxmKcOQ30JU77pCdJJPO-hUjOeRPBwhWu95Yx3i8g3E/s1600/thousandphone.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKL7nu_Bd67zQooFpx3DZJTSRJL4B7JIaQO55rZTqVu7o8fnlaaCY-JY2wv_8mDvbSXujIR5opvgK7mdzDJf-HO2JrJddsPLNuPxmKcOQ30JU77pCdJJPO-hUjOeRPBwhWu95Yx3i8g3E/s320/thousandphone.png&quot; width=&quot;163&quot; /&gt;&lt;/a&gt;
&lt;li&gt;Were you bored with adding to 100 always? Don&#39;t worry. In the new version you can arrange numbers so that they add to 1000. And there are also levels where sum is a random 2 digit number - different number each time. Isn&#39;t it exciting?&lt;/li&gt;
&lt;li&gt;Believe in fast work? For you, there is timed mode. You have to finish a level in 50 seconds. And if you finish much earlier, the remaining time is added as a bonus in next level.&lt;/li&gt;
&lt;li&gt;Do you need a hint? I do not ask you to purchase one. You can use a hint - again one hint per level which is accumulated if unused.&lt;/li&gt;
&lt;/ul&gt;
Does it look quite exciting? &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.shataka&quot; target=&quot;_blank&quot;&gt;Download the game now&lt;/a&gt; and start playing!!! &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/7367681102164838351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/03/shataka-updated.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7367681102164838351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7367681102164838351'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2016/03/shataka-updated.html' title='Shataka updated'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKL7nu_Bd67zQooFpx3DZJTSRJL4B7JIaQO55rZTqVu7o8fnlaaCY-JY2wv_8mDvbSXujIR5opvgK7mdzDJf-HO2JrJddsPLNuPxmKcOQ30JU77pCdJJPO-hUjOeRPBwhWu95Yx3i8g3E/s72-c/thousandphone.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-7981120488327419959</id><published>2015-12-20T06:56:00.001-08:00</published><updated>2015-12-20T06:56:39.201-08:00</updated><title type='text'>Screen recording of your apps</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
You want to publish your app. And you feel the app installs may improve after you add a promo video.&lt;br /&gt;
&lt;br /&gt;
But you are a one-man(or woman) team. And you rarely know anything about creating a video. What do you do?&lt;br /&gt;
&lt;br /&gt;
Screen recording comes to your rescue. You can record your phone screen activities into a video file. All you need is simple android adb tool.&lt;br /&gt;
&lt;br /&gt;
Connect your phone to the laptop.&lt;br /&gt;
&lt;br /&gt;
Go to command prompt.&amp;nbsp; Locate the directory where adb command is present. Normally it is yoursdkdirectory/platform-tools.&lt;br /&gt;
&lt;br /&gt;
And give the command on c&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;adb devices&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You should be able to see your phone listed there.&lt;br /&gt;
&lt;br /&gt;
Next you give command&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;adb shell screenrecord /sdcard/yourfilename.mp4&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now the screen record will start.&amp;nbsp; End it by pressing ^c&lt;br /&gt;
&lt;br /&gt;
The recorded video will be stored in your sdcard.&lt;br /&gt;
&lt;br /&gt;
Copy this to your laptop and you can edit it using moviemaker software in windows&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
The problem with above method is audio will not be recorded and you have to add it in moviemaker. There are many screenrecording apps available in google play. I found AZ screen recorder to be good. You do not need to root the phone and it records audio as well.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Did I finally create the video for my C questions app. I did. But I realized that I have made it worse in movie maker. After spending an entire day on that.&amp;nbsp; &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/7981120488327419959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2015/12/screen-recording-of-your-apps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7981120488327419959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7981120488327419959'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2015/12/screen-recording-of-your-apps.html' title='Screen recording of your apps'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-1957274203928514863</id><published>2015-12-17T06:41:00.001-08:00</published><updated>2015-12-17T06:41:21.210-08:00</updated><title type='text'>Enabling USB debugging on your phone</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Coming here after a very very long time.&lt;br /&gt;
&lt;br /&gt;
Today let us see how to become a developer.&lt;br /&gt;
&lt;br /&gt;
I am kidding. Let us talk about how to enable your device to be connected for debugging in android studio.&lt;br /&gt;
&lt;br /&gt;
You need to install a samsung adb driver for your laptop first of all. Or which phone your brand is.&lt;br /&gt;
&lt;br /&gt;
Next take your phone - go to&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Settings&lt;/li&gt;
&lt;li&gt;About Device&lt;/li&gt;
&lt;li&gt;Build Number - tap on this like 10 times. And your phone tells you now you are a developer.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Great isn&#39;t it. No studying needed.&lt;br /&gt;
&lt;br /&gt;
Do you see your phone in android studio, when you connect to through usb? No, not yet.&lt;br /&gt;
&lt;br /&gt;
Because there is one more step to be done. &lt;br /&gt;
&lt;br /&gt;
Now settings has Developer options in it.&lt;br /&gt;
&lt;br /&gt;
Goto &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Settings&lt;br /&gt;
Developer Options&lt;br /&gt;
USB debugging - check on this&lt;br /&gt;
&lt;br /&gt;
Done !!!&amp;nbsp; Now you can debug your android app on your phone.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/1957274203928514863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2015/12/enabling-usb-debugging-on-your-phone.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1957274203928514863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1957274203928514863'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2015/12/enabling-usb-debugging-on-your-phone.html' title='Enabling USB debugging on your phone'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-9219618475053296440</id><published>2014-11-25T20:49:00.002-08:00</published><updated>2014-11-25T20:49:50.518-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android app"/><category scheme="http://www.blogger.com/atom/ns#" term="Indian newspapers"/><title type='text'>Indian Newspapers and magazines - new version released</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;I have published version 2.0 of my &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.learner.news&amp;amp;hl=en&quot; target=&quot;_blank&quot;&gt;Indian Newspapers and magazines &lt;/a&gt;app for android phone to google play. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;I have added many more papers in regional languages and many more magazines as well. But you don&#39;t have to worry about clutter of all those papers on screen. You can select and deselect only those papers you need.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;As is the new tradition, the categories are displayed as action bar tabs. So you can swipe them.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;And the option to save the files for offline reading is present.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;As some user had commented on advertisement filling lot of real estate on screen, I have tried reducing ad sizes on my part. But some papers publish their own huge ads which are not in my control.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The version does not support android 2.2 as google play has some problems with that. I took that risk as most of the users are having newer versions of android.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;And another omission has been ability to add news papers. I will certainly add that feature in the next bug fix release within a fortnight.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;So download app and give me your valuable suggestions. &lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/9219618475053296440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/11/indian-newspapers-and-magazines-new.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/9219618475053296440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/9219618475053296440'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/11/indian-newspapers-and-magazines-new.html' title='Indian Newspapers and magazines - new version released'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-8599937087201310834</id><published>2014-11-13T22:22:00.000-08:00</published><updated>2014-11-13T22:22:09.267-08:00</updated><title type='text'>Action bar menu items and Fragments</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp;How do we create menu items?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;You can add menu items through code. But the easier method is writing an xml file in ../res/menu folder.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;/res/menu/mymenu.xml &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;item&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/action_settings&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:icon=&quot;@android:drawable/some_icon&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:title=&quot;Customize&quot;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;item&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/action_settings&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:icon=&quot;@android:drawable/some_icon&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:title=&quot;Customize&quot;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;lt;/menu&amp;gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;Next&amp;nbsp; write the onCreateOptionsMenu() method of your fragment like this.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;@Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; MenuInflater mnuInflater = getActivity().getMenuInflater();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mnuInflater.inflate(R.menu.mymenu, menu);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; super.onCreateOptionsMenu(menu, inflater);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;b&gt;Can Fragments add their own action bar menu items?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Yes, They can. To the existing items of activity, these extra menu items can be added by adding the line in the onCreate of the fragment&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; setHasOptionsMenu(true);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;How do we make the menu items appear on action bar always?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the menu xml file add the option showAsAction=&quot;always&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;android:icon=&quot;..youricon&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:showAsAction=&quot;always&quot; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;How do we make the menu items appear on support action bar always?&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the menu xml file add the option compat:showAsAction=&quot;always&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;android:icon=&quot;..youricon&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compat:showAsAction=&quot;always&quot;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;And also add the line&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;xmlns:compat=&quot;http://schemas.android.com/apk/res-auto&quot;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;to first element of xml file&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;That is&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;xmlns:compat=&quot;http://schemas.android.com/apk/res-auto&quot;&amp;nbsp; &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What if fragment option items are not responding to click events&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;onOptionItemSelected &lt;/span&gt;of fragment is executed after same method of parent activity and&lt;b&gt; &lt;/b&gt;&lt;i&gt;only if activity has not consumed it&lt;/i&gt;&lt;b&gt;.&amp;nbsp; &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So make sure you return false in your activity method if &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;itemid &lt;/span&gt;does not match.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;public class MyActivity extends Activity&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;.......&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean onOptionsItemSelected(MenuItem item) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;switch (item.getItemId()) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;case R.id.action_show_offline_pages:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .........&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;return true;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case R.id.somethingelse: do_something_else();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;b&gt;return false;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;} &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;How do I change action bar items dynamically?&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Store the menuItem in the &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;onCreateOptionsMenu()&lt;/span&gt; method&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; as a global variable.&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;MenuInflater inflater = this.getMenuInflater();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; inflater.inflate(R.menu.rsstitlemenu,menu);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mCatMenuItem= menu.findItem(R.id.action_categories);&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Now make&lt;/span&gt; &lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;changes to it when necessary.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;void some_method(){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; mCatMenuItem.setVisible(false);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;....&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/8599937087201310834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/11/action-bar-menu-items-and-fragments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/8599937087201310834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/8599937087201310834'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/11/action-bar-menu-items-and-fragments.html' title='Action bar menu items and Fragments'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-399705550554816912</id><published>2014-10-13T22:22:00.000-07:00</published><updated>2014-10-13T22:22:03.560-07:00</updated><title type='text'>New puzzle &quot;Shataka&quot; published</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I have published a new math puzzle &quot;Shataka&quot; in google play.&lt;br /&gt;
&lt;br /&gt;
This app has a 9 cell empty grid and 9 numbers. Your aim is to drag and drop these numbers into the grid so that each row adds to 100 and each column adds to 100.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span id=&quot;goog_305803676&quot;&gt;&lt;span id=&quot;goog_305803682&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803688&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803695&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803698&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803704&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;https://draft.blogger.com/&quot;&gt;&lt;span id=&quot;goog_305803708&quot;&gt;&lt;/span&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIj_R8-MAhIHT1Da_x9S0q7Civ8Z0z2y_HHUs-AHJ6kRx1EahY9XRYMZ6rc5qYS_L1eamZRYKNYH-hze19KbMoAxfiO6A8_A1mDibYXR3Xnwactn3c-qht5TsaQ7R_wMfX_jQVEG3JgHw/s1600/ssPhone.png&quot; /&gt;&lt;span id=&quot;goog_305803709&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;span id=&quot;goog_305803705&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803699&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803696&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803689&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803683&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803677&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803678&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_305803679&quot;&gt;&lt;/span&gt;&lt;/div&gt;
e.g. In the screen shot above middle column has 87 and 9. So to make column sum 100, you need 100-(87+9). That is 4. And we do have a 4. So drag and drop this 4 in second column. Next first row will have 4 and 28. Hence it needs a 100 -(4+28) which is 68. Drop 68 in first row and first column.&lt;br /&gt;
&lt;br /&gt;
So now you can see that this game is getting interesting.&lt;br /&gt;
&lt;br /&gt;
The screen shot is of level 1. And as you can see, 3 numbers are already given to you. So you need to solve for remaining 6 numbers. In level 2, only 2 numbers are given.&lt;br /&gt;
&lt;br /&gt;
In level 3, 1 number of solution is given. After 3rd level, solution is not given because by then you will not need it. :)&lt;br /&gt;
&lt;br /&gt;
Another helpful feature is after you complete a row or a column, its sum is shown in a popup.&lt;br /&gt;
&lt;br /&gt;
What are you waiting for? Download the app from &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.shataka&quot;&gt;google play &lt;/a&gt;and play non-stop. &lt;br /&gt;
&lt;br /&gt;&lt;span id=&quot;goog_305803684&quot;&gt;&lt;/span&gt;&lt;a href=&quot;https://draft.blogger.com/&quot;&gt;&lt;/a&gt;&lt;span id=&quot;goog_305803685&quot;&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/399705550554816912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/10/new-puzzle-shataka-published.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/399705550554816912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/399705550554816912'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/10/new-puzzle-shataka-published.html' title='New puzzle &quot;Shataka&quot; published'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIj_R8-MAhIHT1Da_x9S0q7Civ8Z0z2y_HHUs-AHJ6kRx1EahY9XRYMZ6rc5qYS_L1eamZRYKNYH-hze19KbMoAxfiO6A8_A1mDibYXR3Xnwactn3c-qht5TsaQ7R_wMfX_jQVEG3JgHw/s72-c/ssPhone.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-7060811383767828128</id><published>2014-07-24T06:05:00.000-07:00</published><updated>2014-08-13T22:43:35.371-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android kannada keyboard"/><category scheme="http://www.blogger.com/atom/ns#" term="Android kannada keyboard with transliteration"/><category scheme="http://www.blogger.com/atom/ns#" term="Hindi keyboard"/><category scheme="http://www.blogger.com/atom/ns#" term="Kannada keyboard"/><category scheme="http://www.blogger.com/atom/ns#" term="kannada transliteration"/><title type='text'>Type in Kannada using Akshara transliteration keyboard</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX9PwJYTpK2V3CdaO7Ij5K35mBZB4dt69-WGW3lYLEkwHCt5kQMlfes7VhsLKGH5dglQ1CuVf1epBQmK2kPdVqRW25v9Cv8pJqUUUow2fuva0AE44oE3sPK1nwoj9FqGRx72QnfV2tdaU/s1600/akshara.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX9PwJYTpK2V3CdaO7Ij5K35mBZB4dt69-WGW3lYLEkwHCt5kQMlfes7VhsLKGH5dglQ1CuVf1epBQmK2kPdVqRW25v9Cv8pJqUUUow2fuva0AE44oE3sPK1nwoj9FqGRx72QnfV2tdaU/s1600/akshara.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;My android app, Akshara Transliteration is now converted into a &lt;b&gt;free app.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFRraJBXpHoQNfeiey2zW2hLVc51AhsygaxZwQMV1aAZWzXhD_Tgiq5n9Qh6ZBLOLs4p1kaZdva3oRkWxyl2QR_HXbgcGD_L67dMS7aDQlEyfo2f_AGboP9V2ZJpY-riZvuLDn2fI-nwc/s1600/kannadaBlue.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFRraJBXpHoQNfeiey2zW2hLVc51AhsygaxZwQMV1aAZWzXhD_Tgiq5n9Qh6ZBLOLs4p1kaZdva3oRkWxyl2QR_HXbgcGD_L67dMS7aDQlEyfo2f_AGboP9V2ZJpY-riZvuLDn2fI-nwc/s1600/kannadaBlue.png&quot; height=&quot;320&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Use the app to type in Kannada or Hindi using Kannada/Hindi on screen keyboard or English QWERTY keyboard with transliteration. Type faster in Kannada. Use predictions. Use Kannada/Hindi numbers. Switch between keyboards.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Download the app at&lt;br /&gt;
&lt;br /&gt;
https://play.google.com/store/apps/details?id=com.hegdeapps.aksharakeyboard&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/7060811383767828128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/07/type-in-kannada-using-akshara.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7060811383767828128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7060811383767828128'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/07/type-in-kannada-using-akshara.html' title='Type in Kannada using Akshara transliteration keyboard'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX9PwJYTpK2V3CdaO7Ij5K35mBZB4dt69-WGW3lYLEkwHCt5kQMlfes7VhsLKGH5dglQ1CuVf1epBQmK2kPdVqRW25v9Cv8pJqUUUow2fuva0AE44oE3sPK1nwoj9FqGRx72QnfV2tdaU/s72-c/akshara.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-4591190584542503525</id><published>2014-07-22T03:21:00.001-07:00</published><updated>2014-07-22T03:21:43.799-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="calendar"/><category scheme="http://www.blogger.com/atom/ns#" term="date"/><category scheme="http://www.blogger.com/atom/ns#" term="simpledateformat"/><title type='text'>Converting String to Date and Date to String in android</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;I struggled almost for an entire day trying to access and manipulate dates for my app. If I use date class, many of the methods show warning that they are deprecated. I took the help of simple date format and tried showing month and date. But some how the output was always wrong.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;So, if you need to access dates, set a date to current date or to any other particular date and also read dates from a edit text, you should ideally use 3 classes&amp;nbsp; viz Calendar, Date and SimpleDateFormat.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;First create a Calendar object and initialize it with current date.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Calendar cal&amp;nbsp; = Calendar.getInstance();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Now to convert this to Date object use getTime() method.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; Date someDate = cal.getTime();//this returns a date object.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Now to get a string representation of this date use SimpleDateFormat class&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SimpleDateFormat dtFormat = new SimpleDateFormat(&quot;dd-MMMM-yyyy&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String dtStr = dtFormat.format(someDate);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;For today&#39;s date i.e. 22-7-2014, the string dtStr will be 22-July-2014.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Some points to note here&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In SimpleDateFormat , d - day, M - is month , y is year&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;For month don&#39;t use lower m. Use M instead. (That mistake caused me hours of struggle).&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If month has 3 or more, it is shown in text, else in number .&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;MM - 07&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;MMM- Jul&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;MMMM-July&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;b&gt;Convert string to date&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;For this use parse method of SimpleDateFormat&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt; SimpleDateFormat formatter = new SimpleDateFormat(&quot;dd-MM-yyyy&quot;); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Date dt = formatter.parse(datestr);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; mCal.setTime(dt);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (ParseException e) {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;b&gt;Setting date or month or year&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;To set any of date, month, year or even hour, minute and second, you can use this method&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;calendarObject.set(Calendar.fieldname,value);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp; e.g.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;mCal.set(Calendar.MONTH,5);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;mCal.set(Calendar.DAY_OF_MONTH,4);&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/4591190584542503525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/07/converting-string-to-date-and-date-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4591190584542503525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/4591190584542503525'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/07/converting-string-to-date-and-date-to.html' title='Converting String to Date and Date to String in android'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-7980575027080999331</id><published>2014-07-10T02:15:00.003-07:00</published><updated>2014-07-15T21:43:18.532-07:00</updated><title type='text'>MemoryPro new version released</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.blogger.com/video.g?token=AD6v5dxAJHNP6k30EMda6rVlZTxkIcE6lNErXWQiGPgyrJJNiYafeUcK260IiZMzGQpi6kEbSYNl9gecyOc9PCAkaw&#39; class=&#39;b-hbp-video b-uploaded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
If you have downloaded my &quot;&lt;a href=&quot;http://myandroidtipsandtricks.blogspot.in/2012/12/test-your-memory-new-app.html?view=flipcard&quot;&gt;test your memory&lt;/a&gt;&quot; app and had liked it, here is a new version of it.&lt;br /&gt;
&lt;br /&gt;
The latest version has patterns memory which is supposedly good for spatial memory. A rectangular grid with some cells filled are shown. You have to remember them and tap the filled cells.&lt;br /&gt;
&lt;br /&gt;
Also I have added sound to clicks (or taps) in each game. Good to play with some sound, right? Of course you can disable sound, if you don&#39;t like it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmAu-1uf-oqaUwHa9md_vtgIHGgl1Ky_tXrWA0UkSHLSjlPULXT8QlFeIkfS3D6wa_lsSNWBrE4ECdViAreos934m22ObDGh48JA-CeoTZVOGP4jk8qxskgOIVzfzb0cA0sfULunKxja8/s1600/patternsSS.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmAu-1uf-oqaUwHa9md_vtgIHGgl1Ky_tXrWA0UkSHLSjlPULXT8QlFeIkfS3D6wa_lsSNWBrE4ECdViAreos934m22ObDGh48JA-CeoTZVOGP4jk8qxskgOIVzfzb0cA0sfULunKxja8/s1600/patternsSS.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-DZBGXFjkyfuU_Iz3ZpOTd7jaNzlGrz7HrQNzquu2DaOIB3aw36x_2Fl0kQj2ii7_OZYZzGQvWZueq9W1_yQSLWrewA6xqm0fTWq_-MOjtxYwqd9gXSucb6kSVT31LMqw9yN5PbG4pws/s1600/cardsss.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-DZBGXFjkyfuU_Iz3ZpOTd7jaNzlGrz7HrQNzquu2DaOIB3aw36x_2Fl0kQj2ii7_OZYZzGQvWZueq9W1_yQSLWrewA6xqm0fTWq_-MOjtxYwqd9gXSucb6kSVT31LMqw9yN5PbG4pws/s1600/cardsss.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.memorygame&quot;&gt;download the game&lt;/a&gt; and enjoy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/7980575027080999331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/07/memorypro-new-version-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7980575027080999331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/7980575027080999331'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/07/memorypro-new-version-released.html' title='MemoryPro new version released'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmAu-1uf-oqaUwHa9md_vtgIHGgl1Ky_tXrWA0UkSHLSjlPULXT8QlFeIkfS3D6wa_lsSNWBrE4ECdViAreos934m22ObDGh48JA-CeoTZVOGP4jk8qxskgOIVzfzb0cA0sfULunKxja8/s72-c/patternsSS.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-8643074549960902485</id><published>2014-04-11T00:39:00.000-07:00</published><updated>2014-04-11T00:39:08.047-07:00</updated><title type='text'>New Akshara keyboard</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are looking for a keyboard which lets you type in Kannada using a simple QWERTY keyboard, Akshara transliteration is your answer.&lt;br /&gt;
&lt;br /&gt;
To download, click on the image below.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.hegdeapps.aksharakeyboard&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv7HTHsW3eBucQDvmpy0FNm_SnF4KH6zVtyIrewOg0AWyCPbp40pPVaoJqQYEapfsZqOl7lYkh1L3OF00gmowmIBEz93AAUInXJqaxhx1Ok8okTYbBupmL4mEfNxEGdnW_vIVUIkFYL6M/s1600/blue.png&quot; height=&quot;320&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Main features of the app are&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Supports Kannada and Hindi. And of course English&lt;/li&gt;
&lt;li&gt;Has transliteration keyboards as well as keyboards with Kannada/ Hindi letters&lt;/li&gt;
&lt;li&gt;Has predictions in all 3 languages&lt;/li&gt;
&lt;li&gt;Number keyboards in Kannada, Hindi and English&lt;/li&gt;
&lt;li&gt;4 different themes&amp;nbsp;&lt;/li&gt;
&lt;li&gt;A simple note pad to type and save your thoughts in your language. This note pad works even if your phone does not have proper font&lt;/li&gt;
&lt;/ul&gt;
Please note that &lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;You should have Kannada/Hindi fonts in your phone to use the app.&lt;/li&gt;
&lt;li&gt;Some phones like lenovo, micromax etc, do not display complex kannada fonts correctly. &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/8643074549960902485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/04/new-akshara-keyboard.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/8643074549960902485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/8643074549960902485'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/04/new-akshara-keyboard.html' title='New Akshara keyboard'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv7HTHsW3eBucQDvmpy0FNm_SnF4KH6zVtyIrewOg0AWyCPbp40pPVaoJqQYEapfsZqOl7lYkh1L3OF00gmowmIBEz93AAUInXJqaxhx1Ok8okTYbBupmL4mEfNxEGdnW_vIVUIkFYL6M/s72-c/blue.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3669293961729061947.post-1856648347373952580</id><published>2014-01-03T22:54:00.002-08:00</published><updated>2014-01-03T22:54:35.431-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android compilation error"/><category scheme="http://www.blogger.com/atom/ns#" term="android import error"/><title type='text'>R.layout.... compilation errors </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
You are working in your android project. Everything was fine. Suddenly you start getting lot of errors. The errors are in all the lines which use R like R.layout, R.drawable etc.&lt;br /&gt;
&lt;br /&gt;
Just check your import statements. Most probably there is an import which says&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;import android.R;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Hence all the resources are tried in android.R., Not in your R.java file.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Remove the import statements. And all these compilations errors vanish&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFdoSpHYA8tQWthDZW93w_NarTKGMuSxlEO7rmv20-sBrnhYcue9rvz2tO6iC8EFszyAIvHImc5YhFNd9AAGR5QpPFAN9nyxLk5QbwJDjwKabTEQQ8CKrZCVlrawqSWw3Yti1SSe46hvo/s1600/androidImportErr.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFdoSpHYA8tQWthDZW93w_NarTKGMuSxlEO7rmv20-sBrnhYcue9rvz2tO6iC8EFszyAIvHImc5YhFNd9AAGR5QpPFAN9nyxLk5QbwJDjwKabTEQQ8CKrZCVlrawqSWw3Yti1SSe46hvo/s1600/androidImportErr.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://myandroidtipsandtricks.blogspot.com/feeds/1856648347373952580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/01/rlayout-compilation-errors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1856648347373952580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3669293961729061947/posts/default/1856648347373952580'/><link rel='alternate' type='text/html' href='http://myandroidtipsandtricks.blogspot.com/2014/01/rlayout-compilation-errors.html' title='R.layout.... compilation errors '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/13247878485630067800</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFdoSpHYA8tQWthDZW93w_NarTKGMuSxlEO7rmv20-sBrnhYcue9rvz2tO6iC8EFszyAIvHImc5YhFNd9AAGR5QpPFAN9nyxLk5QbwJDjwKabTEQQ8CKrZCVlrawqSWw3Yti1SSe46hvo/s72-c/androidImportErr.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>