create account

Android App Development | Lecture#20 | Hive Learners by faisalamin

View this thread on: hive.blogpeakd.comecency.com
· @faisalamin ·
$21.14
Android App Development | Lecture#20 | Hive Learners
<center><h2>𝓖𝓻𝓮𝓮𝓽𝓲𝓷𝓰𝓼</h2></center>
<div class="text-justify">

Hello, beautiful members of Hive Learners, I hope you all are well. Welcome to our 20th lecture on Android App Development. We end with the simple calculator and we learn many new things during the simple calculator development. Today we will start a new app and explore more in Android app development.

![](https://images.ecency.com/DQmctagfaWYD12LjhgrUJvhiaHuRTeyZ4xySVuEEgb7LaJ1/multi_purpose_2_.png)


### [GitHub Link](https://github.com/faisalamin9696/HiveLearners)

Use this GitHub project to clone into your directory. It will constantly get updated in the following lecture so you will never miss the latest code. Happy Coding!.

### What Should I Learn
- Show/Hide a widget
- Use logic to show or hide a widget

### Assignment
- Create Logic to show and hide a widget

### Procedure

I create a new project HiveLearners2. We need to add a button and a textview. Here is the ```main_activity.xml``` code.

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/state_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hide" />

    <TextView
        android:id="@+id/name_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hive Learners"
        android:textSize="20sp"
        android:textStyle="bold" />

</LinearLayout>
```

![](https://images.ecency.com/DQmbzARVigVUoqaNbJLQdW7JozN6W5XEGV8J4yATpDtX9qy/image.png)

Now will declare, initialize and add an on-click listener for the button in the ```Main_Activity.java``` file.

![](https://images.ecency.com/DQmbLLiN5zPwzg5yHgVk9ZqiraEZwgWH1SxJ87G35s3tU7g/image.png)

Now we will use the Visibility function ```setVisibility```. It accepts three parameters, View.VISIBLE, View.INVISIBLEand View.GONE. with View.GONEthe target widget leave our screen and set its height and width to 0.

```
                name_tv.setVisibility(View.INVISIBLE);
```

It will hide the name_tv when state_btn is clicked. Run and check is it working or not.

![](https://images.ecency.com/DQmZFYD1Fj6Mms5vRDJ3t4ENN9B1GYWjNKnrqMCxuJNcF53/image.png)

![](https://images.ecency.com/DQmPegvfbKEHWZddvyYqqxwrthC5vTt2QLFAhQirJEGr9D7/image.png)

Now let's create a login to hide and show the text and also change the text of the button. When the name_tv is hidden button text will be shown and vice versa.</div>

```
 if (name_tv.getVisibility() == View.INVISIBLE) {
                    name_tv.setVisibility(View.VISIBLE);
                    state_btn.setText("HIDE");
                } else {
                    name_tv.setVisibility(View.INVISIBLE);
                    state_btn.setText("SHOW");
                }
```

![](https://images.ecency.com/DQmSwuN3DEdMXr6VujLBmz3iw7rjhVLMT8NXcKrwYAHwkHp/image.png)

<center>
![hl_divider.png](https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png)

<h2>Thank You</h2>

![hl_footer_banner.png](https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png)
<div class="pull-left"><a href="https://discord.gg/7Bzqv4qUMT">
<img src="https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"/></a>
</center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 235 others
properties (23)
authorfaisalamin
permlinkandroid-app-development-or-lecture-d85b1606fc6d1
categoryhive-153850
json_metadata"{"links": ["https://github.com/faisalamin9696/HiveLearners", "http://schemas.android.com/apk/res/android", "http://schemas.android.com/apk/res-auto", "http://schemas.android.com/tools", "https://discord.gg/7Bzqv4qUMT"], "image": ["https://images.ecency.com/DQmctagfaWYD12LjhgrUJvhiaHuRTeyZ4xySVuEEgb7LaJ1/multi_purpose_2_.png", "https://images.ecency.com/DQmbzARVigVUoqaNbJLQdW7JozN6W5XEGV8J4yATpDtX9qy/image.png", "https://images.ecency.com/DQmbLLiN5zPwzg5yHgVk9ZqiraEZwgWH1SxJ87G35s3tU7g/image.png", "https://images.ecency.com/DQmZFYD1Fj6Mms5vRDJ3t4ENN9B1GYWjNKnrqMCxuJNcF53/image.png", "https://images.ecency.com/DQmPegvfbKEHWZddvyYqqxwrthC5vTt2QLFAhQirJEGr9D7/image.png", "https://images.ecency.com/DQmSwuN3DEdMXr6VujLBmz3iw7rjhVLMT8NXcKrwYAHwkHp/image.png", "https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png", "https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png", "https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"], "thumbnails": ["https://images.ecency.com/DQmctagfaWYD12LjhgrUJvhiaHuRTeyZ4xySVuEEgb7LaJ1/multi_purpose_2_.png", "https://images.ecency.com/DQmbzARVigVUoqaNbJLQdW7JozN6W5XEGV8J4yATpDtX9qy/image.png", "https://images.ecency.com/DQmbLLiN5zPwzg5yHgVk9ZqiraEZwgWH1SxJ87G35s3tU7g/image.png", "https://images.ecency.com/DQmZFYD1Fj6Mms5vRDJ3t4ENN9B1GYWjNKnrqMCxuJNcF53/image.png", "https://images.ecency.com/DQmPegvfbKEHWZddvyYqqxwrthC5vTt2QLFAhQirJEGr9D7/image.png", "https://images.ecency.com/DQmSwuN3DEdMXr6VujLBmz3iw7rjhVLMT8NXcKrwYAHwkHp/image.png", "https://images.ecency.com/DQmabQycJhW8DT8a634z3wQaVXvPZ5KMii2LYbaWZ3PsaRy/hl_divider.png", "https://images.ecency.com/DQmZ4HF3hjV4HwJXuw8vRJ6B6CiMC3kUkkoihjtm7z2Gii7/hl_footer_banner.png", "https://cdn.steemitimages.com/DQmXd6PwGUHRgSDkWtwKfDvdFpaLHXvXBdK7wnYZeqe1GUa/discord_animation_logo.gif"], "tags": ["hive-153850", "hl-exclusive", "hl-course", "stem", "educaion", "android", "programming", "pakistan", "study", "coding", "development"], "description": "", "app": "ecency/3.0.24-vision", "format": "markdown+html"}"
created2022-07-03 13:00:15
last_update2022-07-03 13:00:15
depth0
children9
last_payout2022-07-10 13:00:15
cashout_time1969-12-31 23:59:59
total_payout_value10.604 HBD
curator_payout_value10.534 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,653
author_reputation104,701,778,605,493
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,530,822
net_rshares33,329,982,685,129
author_curate_reward""
vote details (299)
@curation-cartel ·
![1UP-PIZZA.png](https://files.peakd.com/file/peakd-hive/curation-cartel/23xediR4hotaNsS5pUJrmYVg3YGeTLpui41uCij2jhUDZ4uFT84zoGJf8a8VnfELXLJgt.png) |  <div class="phishy"><u><h4>You have received a __1UP__ from @gwajnberg!</h4></u></div> The @oneup-cartel will soon upvote you with:<hr> __@stem-curator__ <hr>_And they will bring !PIZZA 🍕._
-|-

<sup>[Learn more](https://peakd.com/hive-102223/@flauwy/the-curation-cartel-1up-trigger-smart-voting-mana-and-high-delegation-returns-for-14-different-tribes) about our delegation service to earn daily rewards. Join the Cartel on [Discord](https://discord.gg/mvtAneE3Ca).</sup>
properties (22)
authorcuration-cartel
permlinkre-android-app-development-or-lecture-d85b1606fc6d1-20220703t152444z
categoryhive-153850
json_metadata"{"app": "beem/0.24.26"}"
created2022-07-03 15:24:45
last_update2022-07-03 15:24:45
depth1
children0
last_payout2022-07-10 15:24:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length623
author_reputation1,123,281,846,602
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,533,625
net_rshares0
@diyhub ·
<div class="pull-right"><a href="https://steempeak.com/trending/hive-189641"><img src="https://cdn.steemitimages.com/DQmV9e1dikviiK47vokoSCH3WjuGWrd6PScpsgEL8JBEZp5/icon_comments.png"></a></div>

###### Thank you for sharing this amazing post on HIVE!

- Your content got selected by our fellow curator @priyanarc & you just received a little thank you via an upvote from our **non-profit** curation initiative!

- You will be **featured in** one of our recurring **curation compilations** and on our **pinterest** boards! Both are aiming to offer you a **stage to widen your audience** within and outside of the DIY scene of hive.

**Join** the official [DIYHub community on HIVE](https://peakd.com/trending/hive-189641) and show us more of your amazing work and feel free to connect with us and other DIYers via our discord server: https://discord.gg/mY5uCfQ !

If you want to support our goal to motivate other DIY/art/music/homesteading/... creators just delegate to us and earn 100% of your curation rewards!

###### Stay creative & hive on!
properties (22)
authordiyhub
permlinkre-android-app-development-or-lecture-d85b1606fc6d1-20220706t181808z
categoryhive-153850
json_metadata"{"app": "beem/0.24.26"}"
created2022-07-06 18:18:09
last_update2022-07-06 18:18:09
depth1
children0
last_payout2022-07-13 18:18:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,046
author_reputation361,701,426,461,443
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,623,977
net_rshares0
@gwajnberg ·
Interesting the code behind the logic of hiding a widget!
!1UP
👍  , , ,
properties (23)
authorgwajnberg
permlinkre-faisalamin-202273t92217603z
categoryhive-153850
json_metadata{"tags":["hive-153850","hl-exclusive","hl-course","stem","educaion","android","programming","pakistan","study","coding","development"],"app":"ecency/3.0.30-mobile","format":"markdown+html"}
created2022-07-03 15:22:18
last_update2022-07-03 15:22:18
depth1
children1
last_payout2022-07-10 15:22:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length62
author_reputation149,874,346,204,072
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,533,570
net_rshares1,871,289,617
author_curate_reward""
vote details (4)
@faisalamin ·
properties (23)
authorfaisalamin
permlinkre-gwajnberg-202274t1409484z
categoryhive-153850
json_metadata{"tags":["hive-153850","hl-exclusive","hl-course","stem","educaion","android","programming","pakistan","study","coding","development"],"app":"ecency/3.0.24-vision","format":"markdown+html"}
created2022-07-04 09:00:12
last_update2022-07-04 09:00:12
depth2
children0
last_payout2022-07-11 09:00:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation104,701,778,605,493
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,554,352
net_rshares1,836,319,465
author_curate_reward""
vote details (4)
@marbrym ·
Excellent information. I Will try to found the before content, because I want to learn to programer in android.
properties (22)
authormarbrym
permlinkre-faisalamin-reqfsi
categoryhive-153850
json_metadata{"tags":["hive-153850"],"app":"peakd/2022.05.9"}
created2022-07-09 02:48:18
last_update2022-07-09 02:48:18
depth1
children2
last_payout2022-07-16 02:48:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length111
author_reputation59,067,129,356,825
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,692,140
net_rshares0
@faisalamin ·
Thank You. You can follow this Android App Development course
👍  
properties (23)
authorfaisalamin
permlinkre-marbrym-202279t135118445z
categoryhive-153850
json_metadata{"tags":["hive-153850"],"app":"ecency/3.0.24-vision","format":"markdown+html"}
created2022-07-09 08:51:21
last_update2022-07-09 08:51:21
depth2
children1
last_payout2022-07-16 08:51:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length61
author_reputation104,701,778,605,493
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,697,076
net_rshares35,715,816,496
author_curate_reward""
vote details (1)
@marbrym ·
Ir Is a great idea! Thank you!
properties (22)
authormarbrym
permlinkre-faisalamin-202279t205446232z
categoryhive-153850
json_metadata{"tags":["hive-153850"],"app":"ecency/3.0.30-mobile","format":"markdown+html"}
created2022-07-10 00:54:48
last_update2022-07-10 00:54:48
depth3
children0
last_payout2022-07-17 00:54:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length30
author_reputation59,067,129,356,825
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,715,279
net_rshares0
@pizzabot ·
<center>PIZZA! 


PIZZA Holders sent <strong>$PIZZA</strong> tips in this post's comments:
@curation-cartel<sub>(6/20)</sub> tipped @faisalamin (x1)


<sub>Join us in <a href="https://discord.gg/hivepizza">Discord</a>!</sub></center>
properties (22)
authorpizzabot
permlinkre-android-app-development-or-lecture-d85b1606fc6d1-20220703t152557z
categoryhive-153850
json_metadata"{"app": "beem/0.24.26"}"
created2022-07-03 15:25:57
last_update2022-07-03 15:25:57
depth1
children0
last_payout2022-07-10 15:25:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length233
author_reputation6,158,205,626,770
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,533,653
net_rshares0
@stemsocial ·
re-faisalamin-android-app-development-or-lecture-d85b1606fc6d1-20220703t140852707z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-faisalamin-android-app-development-or-lecture-d85b1606fc6d1-20220703t140852707z
categoryhive-153850
json_metadata{"app":"STEMsocial"}
created2022-07-03 14:08:54
last_update2022-07-03 14:08:54
depth1
children0
last_payout2022-07-10 14:08:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,460,334,324,555
root_title"Android App Development | Lecture#20 | Hive Learners"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id114,532,135
net_rshares0