tag:blogger.com,1999:blog-38257064244051652682024-03-13T23:52:26.535+08:00How-To Tutorials & Source Code by Tuts CodeA blog that makes basic programming tutorials. May be useful.Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comBlogger71125tag:blogger.com,1999:blog-3825706424405165268.post-90083746119650838432020-05-04T21:12:00.003+08:002020-12-15T10:44:20.563+08:00Face Detection Using Python and OpenCV<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-5uIuvpu5QMk/XrARwxHqZlI/AAAAAAAABkU/mktvfQsJeEY6LgotfziZ-3uq205Dw9_SQCLcBGAsYHQ/s1600/FACE%2BDETECTION.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" src="https://1.bp.blogspot.com/-5uIuvpu5QMk/XrARwxHqZlI/AAAAAAAABkU/mktvfQsJeEY6LgotfziZ-3uq205Dw9_SQCLcBGAsYHQ/s1600/FACE%2BDETECTION.jpg" /></a></div>
<br />
Hello friend, in this post we will create a "Face Detection" program using the <b>OpenCV</b> library using the Python programming language.<b> "Face Detection"</b> is a program that can recognize a face in a frame, be it in the form of images or videos. One use of this technique is the attendance process carried out in an agency so that there is no forgery of attendance.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
First, open your editor, here I use PyCharm then create a file named "<b>index.py</b>". When done, make sure you already have the file <b>"haarcascade_frontalface_default.xml"</b> if you don't have it, please download <a href="https://drive.google.com/open?id=1834sEAsOwiVmVoOxCM7AiFCFLFuf7dG3" target="_blank">here</a> and put it in the same folder as "<b>index.py</b>"<br />
<br />
Open <b>index.py</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">cv2</span>
faceCascade <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>CascadeClassifier(<span style="color: #cc3300;">"haarcascade_frontalface_default.xml"</span>)
cam <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>VideoCapture(<span style="color: #ff6600;">0</span>)
</pre>
</div>
<br />
First, we import the OpenCV library, then we load the <b>haarcascade_frontalface_default.xml</b> file into the "faceCascade" variable, then activate the camera loaded in the "cam" variable<br />
<br />
<b>Note :</b> If you use an external camera, please change <b>cv2.VideoCapture (0)</b> to <b>cv2.VideoCapture (1)</b><br />
<br />
Next, enter the code below<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">while</span> <span style="color: #006699; font-weight: bold;">True</span>:
ret, im <span style="color: #555555;">=</span> cam<span style="color: #555555;">.</span>read()
gray <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>cvtColor(im, cv2<span style="color: #555555;">.</span>COLOR_BGR2GRAY)
faces <span style="color: #555555;">=</span> faceCascade<span style="color: #555555;">.</span>detectMultiScale(gray, <span style="color: #ff6600;">1.2</span>,<span style="color: #ff6600;">5</span>)
</pre>
</div>
<br />
The above code serves to do continuous looping on the code inside<br />
<ul>
<li>Every frame taken using an external webcam or camera is entered into the variable "im"</li>
<li>Converting to Gray mode variable "im"</li>
<li>Detect all faces in the frame</li>
</ul>
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Next, enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;"> for</span>(x,y,w,h) <span style="color: black; font-weight: bold;">in</span> faces:
cv2<span style="color: #555555;">.</span>rectangle(im, (x<span style="color: #555555;">-</span><span style="color: #ff6600;">20</span>,y<span style="color: #555555;">-</span><span style="color: #ff6600;">20</span>), (x<span style="color: #555555;">+</span>w<span style="color: #555555;">+</span><span style="color: #ff6600;">20</span>, y<span style="color: #555555;">+</span>h<span style="color: #555555;">+</span><span style="color: #ff6600;">20</span>), (<span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">255</span>,<span style="color: #ff6600;">0</span>), <span style="color: #ff6600;">4</span>)
cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">'Face Detection'</span>, im)
</pre>
</div>
<br />
The code above serves to make a green box in the face area that is detected in the frame. Then display in a new window with the name "<b>Face Detection</b>". When finished, enter the following closing code so that the window still appears.<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;"> if</span> cv2<span style="color: #555555;">.</span>waitKey(<span style="color: #ff6600;">10</span>) <span style="color: #555555;">&</span> <span style="color: #ff6600;">0xFF</span> <span style="color: #555555;">==</span> <span style="color: #336666;">ord</span>(<span style="color: #cc3300;">'q'</span>):
<span style="color: #006699; font-weight: bold;">break</span>
cam<span style="color: #555555;">.</span>release()
cv2<span style="color: #555555;">.</span>destroyAllWindows()
</pre>
</div>
<br />
At this point, the program is ready to run.<br />
<br />
<h3>
Full Source Code :</h3>
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">cv2</span>
faceCascade <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>CascadeClassifier(<span style="color: #cc3300;">"haarcascade_frontalface_default.xml"</span>)
cam <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>VideoCapture(<span style="color: #ff6600;">0</span>)
<span style="color: #006699; font-weight: bold;">while</span> <span style="color: #006699; font-weight: bold;">True</span>:
ret, im <span style="color: #555555;">=</span> cam<span style="color: #555555;">.</span>read()
gray <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>cvtColor(im, cv2<span style="color: #555555;">.</span>COLOR_BGR2GRAY)
faces <span style="color: #555555;">=</span> faceCascade<span style="color: #555555;">.</span>detectMultiScale(gray, <span style="color: #ff6600;">1.2</span>,<span style="color: #ff6600;">5</span>)
<span style="color: #006699; font-weight: bold;">for</span>(x,y,w,h) <span style="color: black; font-weight: bold;">in</span> faces:
cv2<span style="color: #555555;">.</span>rectangle(im, (x<span style="color: #555555;">-</span><span style="color: #ff6600;">20</span>,y<span style="color: #555555;">-</span><span style="color: #ff6600;">20</span>), (x<span style="color: #555555;">+</span>w<span style="color: #555555;">+</span><span style="color: #ff6600;">20</span>, y<span style="color: #555555;">+</span>h<span style="color: #555555;">+</span><span style="color: #ff6600;">20</span>), (<span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">255</span>,<span style="color: #ff6600;">0</span>), <span style="color: #ff6600;">4</span>)
cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">'Face Detection'</span>, im)
<span style="color: #006699; font-weight: bold;">if</span> cv2<span style="color: #555555;">.</span>waitKey(<span style="color: #ff6600;">10</span>) <span style="color: #555555;">&</span> <span style="color: #ff6600;">0xFF</span> <span style="color: #555555;">==</span> <span style="color: #336666;">ord</span>(<span style="color: #cc3300;">'q'</span>):
<span style="color: #006699; font-weight: bold;">break</span>
cam<span style="color: #555555;">.</span>release()
cv2<span style="color: #555555;">.</span>destroyAllWindows()
</pre>
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/alqnuZ3tZjw/0.jpg" frameborder="0" height="370" src="https://www.youtube.com/embed/alqnuZ3tZjw?feature=player_embedded" width="100%"></iframe></div>
<br />Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comtag:blogger.com,1999:blog-3825706424405165268.post-20366110574220134772020-04-28T12:56:00.000+08:002020-04-28T13:08:39.160+08:00How to Change Perspective Image With Python and OpenCV<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-T0Ch_ybqZ5w/XqVQ8pWxcMI/AAAAAAAABjs/KttAVoBJjdEdfpW3ATZkf1ahdWltD5wwACLcBGAsYHQ/s1600/perspective%2Bmethod%2Bbird%2Beye.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" src="https://1.bp.blogspot.com/-T0Ch_ybqZ5w/XqVQ8pWxcMI/AAAAAAAABjs/KttAVoBJjdEdfpW3ATZkf1ahdWltD5wwACLcBGAsYHQ/s1600/perspective%2Bmethod%2Bbird%2Beye.jpg" /></a></div>
<br />
<br />
Hello friends, in this post I will share a little about how to apply the "Bird's Eye" method by using the OpenCV library in the Python programming language using the PyCharm IDE. So, "Bird's Eye" is a term in looking at an image with a Top-Down perspective from top to bottom.<br />
<br />
This method is quite popularly used in "machine learning" for example in the case of "Lane Detection", "Measuring Car Distance" and of course many more.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Okay, just first open the<b> PyCharm IDE</b> then create a new file with the name <b>index.py</b> and include an image where the object is visible from the perspective from the bottom, more or less like in the image I use.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-4WjysXfvOtM/XqVFPMyx9DI/AAAAAAAABiw/KO0FYdzWhd0yY8lAGYSt8biNnZMnZGl4gCLcBGAsYHQ/s1600/book.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="593" data-original-width="800" src="https://1.bp.blogspot.com/-4WjysXfvOtM/XqVFPMyx9DI/AAAAAAAABiw/KO0FYdzWhd0yY8lAGYSt8biNnZMnZGl4gCLcBGAsYHQ/s1600/book.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">book.jpg</td></tr>
</tbody></table>
<br />
If the image is ready, then we enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">cv2</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">numpy</span> <span style="color: #006699; font-weight: bold;">as</span> <span style="color: #00ccff; font-weight: bold;">np</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">matplotlib.pyplot</span> <span style="color: #006699; font-weight: bold;">as</span> <span style="color: #00ccff; font-weight: bold;">plt</span>
img <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>imread(<span style="color: #cc3300;">"book.jpg"</span>)
cv2<span style="color: #555555;">.</span>circle(img, (<span style="color: #ff6600;">215</span>, <span style="color: #ff6600;">35</span>), <span style="color: #ff6600;">5</span>, (<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">255</span>), <span style="color: #555555;">-</span><span style="color: #ff6600;">1</span>) <span style="color: #0099ff; font-style: italic;"># top left</span>
cv2<span style="color: #555555;">.</span>circle(img, (<span style="color: #ff6600;">550</span>, <span style="color: #ff6600;">25</span>), <span style="color: #ff6600;">5</span>, (<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">255</span>), <span style="color: #555555;">-</span><span style="color: #ff6600;">1</span>) <span style="color: #0099ff; font-style: italic;"># top right</span>
cv2<span style="color: #555555;">.</span>circle(img, (<span style="color: #ff6600;">130</span>, <span style="color: #ff6600;">370</span>), <span style="color: #ff6600;">5</span>, (<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">255</span>), <span style="color: #555555;">-</span><span style="color: #ff6600;">1</span>) <span style="color: #0099ff; font-style: italic;"># bottom left</span>
cv2<span style="color: #555555;">.</span>circle(img, (<span style="color: #ff6600;">630</span>, <span style="color: #ff6600;">370</span>), <span style="color: #ff6600;">5</span>, (<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">255</span>), <span style="color: #555555;">-</span><span style="color: #ff6600;">1</span>) <span style="color: #0099ff; font-style: italic;"># bottom right</span>
cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">"Image"</span>, img)
cv2<span style="color: #555555;">.</span>waitKey(<span style="color: #ff6600;">0</span>)
</pre>
</div>
<br />
The code above serves to save the picture "book.jpg" into the variable "img", then we put a red dot to adjust the location of the coordinates of the book picture corner. Actually this is not necessary, but it helps us in determining the location of the coordinates.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
<b>Note :</b> <b>Customize your picture.</b><br />
<br />
If the above program is run it will appear like this<br />
<br />
<b> </b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-Ss_-WwYSCx8/XqVGyjuDlgI/AAAAAAAABi8/EyROVwebJ_kG8JJqAnC5aDsWgdwu6co_ACLcBGAsYHQ/s1600/cv2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="784" data-original-width="1005" height="311" src="https://1.bp.blogspot.com/-Ss_-WwYSCx8/XqVGyjuDlgI/AAAAAAAABi8/EyROVwebJ_kG8JJqAnC5aDsWgdwu6co_ACLcBGAsYHQ/s400/cv2.png" width="400" /></a></div>
<b> </b><br />
<br />
If it is suitable, then you just delete the code below<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">"Image"</span>, img)
cv2<span style="color: #555555;">.</span>waitKey(<span style="color: #ff6600;">0</span>)
</pre>
</div>
<br />
Continue with the next code<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">pts1 <span style="color: #555555;">=</span> np<span style="color: #555555;">.</span>float32(
[[<span style="color: #ff6600;">215</span>,<span style="color: #ff6600;">35</span>], <span style="color: #0099ff; font-style: italic;"># top left</span>
[<span style="color: #ff6600;">550</span>,<span style="color: #ff6600;">25</span>], <span style="color: #0099ff; font-style: italic;"># top right</span>
[<span style="color: #ff6600;">130</span>,<span style="color: #ff6600;">370</span>], <span style="color: #0099ff; font-style: italic;"># bottom left</span>
[<span style="color: #ff6600;">630</span>,<span style="color: #ff6600;">370</span>]] <span style="color: #0099ff; font-style: italic;"># bottom right</span>
)
pts2 <span style="color: #555555;">=</span> np<span style="color: #555555;">.</span>float32(
[[<span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">0</span>], <span style="color: #0099ff; font-style: italic;"># top left</span>
[<span style="color: #ff6600;">500</span>,<span style="color: #ff6600;">0</span>], <span style="color: #0099ff; font-style: italic;"># top right</span>
[<span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">600</span>], <span style="color: #0099ff; font-style: italic;"># bottom left</span>
[<span style="color: #ff6600;">500</span>,<span style="color: #ff6600;">600</span>]] <span style="color: #0099ff; font-style: italic;"># bottom right</span>
)
matrix <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getPerspectiveTransform(pts1,pts2)
result <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>warpPerspective(img, matrix, (<span style="color: #ff6600;">500</span>,<span style="color: #ff6600;">600</span>)) <span style="color: #0099ff; font-style: italic;"># set size image based on pts2 (w = 500 h = 600)</span>
</pre>
</div>
<br />
<b>pts1 </b>is the coordinate point of the corner of the book, adjusting to the previous red dot.<br />
<br />
<b>pts2 </b>is the coordinate point that we made to determine the width and height of the image to be produced.<br />
Next we call the "cv2.getPerspectiveTransform" function based on the <b>pts1 </b>and <b>pts2 </b>variables stored in the <b>matrix </b>variable. Then in the <b>result </b>variable we call the "cv2.warpPerspective" function with parameters (original image, matrix and image size)<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
The last stage, we display the original image and the resulting image using the library "matplotlib.pyplot"<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">plt<span style="color: #555555;">.</span>subplot(<span style="color: #ff6600;">1</span>,<span style="color: #ff6600;">2</span>,<span style="color: #ff6600;">1</span>),
plt<span style="color: #555555;">.</span>imshow(cv2<span style="color: #555555;">.</span>cvtColor(img,cv2<span style="color: #555555;">.</span>COLOR_BGR2RGB))
plt<span style="color: #555555;">.</span>title(<span style="color: #cc3300;">'Original Image'</span>)
plt<span style="color: #555555;">.</span>subplot(<span style="color: #ff6600;">1</span>,<span style="color: #ff6600;">2</span>,<span style="color: #ff6600;">2</span>),
plt<span style="color: #555555;">.</span>imshow(cv2<span style="color: #555555;">.</span>cvtColor(result,cv2<span style="color: #555555;">.</span>COLOR_BGR2RGB))
plt<span style="color: #555555;">.</span>title(<span style="color: #cc3300;">'Result'</span>)
plt<span style="color: #555555;">.</span>show()
cv2<span style="color: #555555;">.</span>waitKey(<span style="color: #ff6600;">0</span>)
</pre>
</div>
<br />
The following explanation above code :<br />
<br />
<ol>
<li>Define a plot consisting of (1 row, 2 columns, placement at position 1)</li>
<li>Ready to display the original image "img" in its original color</li>
<li>Set image title</li>
<li>Define a plot consisting of (1 row, 2 columns, placement at position 2)</li>
<li>Ready to display image "result"</li>
<li>Set image title</li>
<li>Show plot</li>
<li>Hold the window to keep it appearing</li>
</ol>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-EQlx7OT3sXE/XqVPB4IVwyI/AAAAAAAABjg/1MAe_bNbzWQzXwyEvrRlpwR9o_8bJIEHwCLcBGAsYHQ/s1600/cv22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1030" data-original-width="1308" height="502" src="https://1.bp.blogspot.com/-EQlx7OT3sXE/XqVPB4IVwyI/AAAAAAAABjg/1MAe_bNbzWQzXwyEvrRlpwR9o_8bJIEHwCLcBGAsYHQ/s640/cv22.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/jka7ZYuXNTY/0.jpg" frameborder="0" height="370" src="https://www.youtube.com/embed/jka7ZYuXNTY?feature=player_embedded" width="100%"></iframe></div>
<br />
<ol></ol>
Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comtag:blogger.com,1999:blog-3825706424405165268.post-52250556021607857322020-04-25T15:27:00.000+08:002020-04-25T16:32:45.700+08:00Color Detection With Python and OpenCV<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-0XLyOf4u7ns/XqPjLUybcWI/AAAAAAAABiM/lmu-Qw1rkFo7YwTI4gOx8BWqFOKR3v2RgCLcBGAsYHQ/s1600/COLOR%2BDETECTION%2BHSV.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" src="https://1.bp.blogspot.com/-0XLyOf4u7ns/XqPjLUybcWI/AAAAAAAABiM/lmu-Qw1rkFo7YwTI4gOx8BWqFOKR3v2RgCLcBGAsYHQ/s1600/COLOR%2BDETECTION%2BHSV.jpg" /></a></div><br />
<br />
Hello friends, in this tutorial I will create a programming program using <b>OpenCV </b>colors using the Python programming language.<br />
<br />
So, for those who don't know <b>OpenCV </b>is an open-source library that can be used for real-time dynamic image processing, created by Intel, and now supported by Willow Garage and Itseez. I made this program using the <b>PyCharm JetBrains </b>IDE.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
First, open your PyCharm and then create a new file, for example I use the name "index.py" and add an image that has a variety of colors like this<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-JGXch9FucRY/XqPb_S9_1OI/AAAAAAAABho/SaZ6a80jll0MreKGuikxg8F25OZFhuvewCLcBGAsYHQ/s1600/colors.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="348" data-original-width="568" src="https://1.bp.blogspot.com/-JGXch9FucRY/XqPb_S9_1OI/AAAAAAAABho/SaZ6a80jll0MreKGuikxg8F25OZFhuvewCLcBGAsYHQ/s1600/colors.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">colors.png</td></tr>
</tbody></table>If you have typed the following code in <b>index.py</b><!-- HTML generated using hilite.me --><br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">cv2</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">numpy</span> <span style="color: #006699; font-weight: bold;">as</span> <span style="color: #00ccff; font-weight: bold;">np</span>
<span style="color: #006699; font-weight: bold;">def</span> <span style="color: #cc00ff;">empty</span>(a):
<span style="color: #006699; font-weight: bold;">pass</span>
<span style="color: #0099ff; font-style: italic;"># create new window with trackbar for HSV Color</span>
cv2<span style="color: #555555;">.</span>namedWindow(<span style="color: #cc3300;">"Range HSV"</span>)
cv2<span style="color: #555555;">.</span>resizeWindow(<span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">500</span>, <span style="color: #ff6600;">350</span>)
cv2<span style="color: #555555;">.</span>createTrackbar(<span style="color: #cc3300;">"HUE Min"</span>, <span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">180</span>,empty)
cv2<span style="color: #555555;">.</span>createTrackbar(<span style="color: #cc3300;">"HUE Max"</span>, <span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">180</span>,<span style="color: #ff6600;">180</span>,empty)
cv2<span style="color: #555555;">.</span>createTrackbar(<span style="color: #cc3300;">"SAT Min"</span>, <span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">255</span>,empty)
cv2<span style="color: #555555;">.</span>createTrackbar(<span style="color: #cc3300;">"SAT Max"</span>, <span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">255</span>,<span style="color: #ff6600;">255</span>,empty)
cv2<span style="color: #555555;">.</span>createTrackbar(<span style="color: #cc3300;">"VALUE Min"</span>, <span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">0</span>,<span style="color: #ff6600;">255</span>,empty)
cv2<span style="color: #555555;">.</span>createTrackbar(<span style="color: #cc3300;">"VALUE Max"</span>, <span style="color: #cc3300;">"Range HSV"</span>, <span style="color: #ff6600;">255</span>,<span style="color: #ff6600;">255</span>,empty)
<span style="color: #0099ff; font-style: italic;"># read image</span>
image <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>imread(<span style="color: #cc3300;">"colors.png"</span>)
</pre></div><br />
In the above code, we enter the required libraries namely <b>cv2 </b>and <b>numpy</b>, then we create an <i>empty</i> function. Then we create a new window with the name HSV Range in which will contain 6 trackbar and the last we create a variable with the name of the <b>image </b>to read the image to be inserted.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
If we have entered the next code<!-- HTML generated using hilite.me --><br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: none gray; overflow: auto; padding: 0.6em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">while</span> <span style="color: #006699; font-weight: bold;">True</span>:
<span style="color: #0099ff; font-style: italic;"># get value from trackbar</span>
h_min <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getTrackbarPos(<span style="color: #cc3300;">"HUE Min"</span>, <span style="color: #cc3300;">"Range HSV"</span>)
h_max <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getTrackbarPos(<span style="color: #cc3300;">"HUE Max"</span>, <span style="color: #cc3300;">"Range HSV"</span>)
s_min <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getTrackbarPos(<span style="color: #cc3300;">"SAT Min"</span>, <span style="color: #cc3300;">"Range HSV"</span>)
s_max <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getTrackbarPos(<span style="color: #cc3300;">"SAT Max"</span>, <span style="color: #cc3300;">"Range HSV"</span>)
v_min <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getTrackbarPos(<span style="color: #cc3300;">"VALUE Min"</span>, <span style="color: #cc3300;">"Range HSV"</span>)
v_max <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>getTrackbarPos(<span style="color: #cc3300;">"VALUE Max"</span>, <span style="color: #cc3300;">"Range HSV"</span>)
<span style="color: #0099ff; font-style: italic;"># define range of some color in HSV</span>
lower_range <span style="color: #555555;">=</span> np<span style="color: #555555;">.</span>array([h_min,s_min,v_min])
upper_range <span style="color: #555555;">=</span> np<span style="color: #555555;">.</span>array([h_max, s_max, v_max])
<span style="color: #0099ff; font-style: italic;"># convert image to HSV</span>
hsv <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>cvtColor(image, cv2<span style="color: #555555;">.</span>COLOR_BGR2HSV)
<span style="color: #0099ff; font-style: italic;"># threshold the hsv image to get some color</span>
thresh <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>inRange(hsv, lower_range, upper_range)
<span style="color: #0099ff; font-style: italic;"># bitwise AND mask and original image</span>
bitwise <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>bitwise_and(image, image, mask<span style="color: #555555;">=</span>thresh)
cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">"Original Image"</span>, image)
cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">"Thresholded"</span>, thresh)
cv2<span style="color: #555555;">.</span>imshow(<span style="color: #cc3300;">"Bitwise"</span>, bitwise)
k <span style="color: #555555;">=</span> cv2<span style="color: #555555;">.</span>waitKey(<span style="color: #ff6600;">1</span>) <span style="color: #555555;">&</span> <span style="color: #ff6600;">0xFF</span>
<span style="color: #006699; font-weight: bold;">if</span> k <span style="color: #555555;">==</span> <span style="color: #336666;">ord</span>(<span style="color: #cc3300;">'m'</span>):
mode <span style="color: #555555;">=</span> <span style="color: black; font-weight: bold;">not</span> mode
<span style="color: #006699; font-weight: bold;">elif</span> k <span style="color: #555555;">==</span> <span style="color: #ff6600;">27</span>:
<span style="color: #006699; font-weight: bold;">break</span>
cv2<span style="color: #555555;">.</span>destroyAllWindows()
</pre></div><br />
The code above is a looping continuously, inside there are several variables, i.e.<br />
<br />
<ul><li>h_min : to store numeric values from the trackbar with the name<b> HUE Min</b></li>
<li>h_max : to store numeric values from the trackbar with the name<b> HUE Max</b></li>
<li>s_min : to store numeric values from the trackbar with the name<b> SAT Min</b></li>
<li>s_max : to store numeric values from the trackbar with the name<b> SAT Max</b></li>
<li>v_min : to store numeric values from the trackbar with the name<b> VALUE Min</b></li>
<li>v_max : to store numeric values from the trackbar with the name<b> VALUE Max</b></li>
</ul><br />
Next, there are <b>lower_range</b> and <b>upper_range</b> variables, where <b>lower_range</b> will store the values of HUE Min, SAT Min and VALUE Min in the form of arrays. Where as <b>upper_range</b> is to store HUE Max, SAT Max and VALUE Max values in an array.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
Next we convert the <b>image </b>variable into <b>HSV </b>mode which is stored in the <b>hsv</b> variable. Furthermore, the hsv variable was masked or threshold based on the range of values of the <b>lower_range</b> and <b>upper_range</b> variables. Finally in the <b>bitwise</b> variable we display the detected color.<br />
<br />
If it's finished, we display these variables, namely <b>image, thresh </b>and <b>bitwise</b>. The code snippet below works so that the form doesn't close immediately, meaning that if we want to close it we need to press the "m" button on the keyboard.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-GnKQP3R6bkg/XqPhvOL5u5I/AAAAAAAABiA/UL8DdPZwb2IDYCO3HIK7taEuakG9BdNEgCLcBGAsYHQ/s1600/resultcolordetct.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="973" data-original-width="1443" src="https://1.bp.blogspot.com/-GnKQP3R6bkg/XqPhvOL5u5I/AAAAAAAABiA/UL8DdPZwb2IDYCO3HIK7taEuakG9BdNEgCLcBGAsYHQ/s1600/resultcolordetct.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Results</td></tr>
</tbody></table><br />
<h3>For more details, please watch the video below</h3><div class="separator" style="clear: both; text-align: center;"><iframe width="100%" height="370" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/dc9dKkJZ2AU/0.jpg" src="https://www.youtube.com/embed/dc9dKkJZ2AU?feature=player_embedded" frameborder="0" allowfullscreen></iframe> </div>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comtag:blogger.com,1999:blog-3825706424405165268.post-68584326130263288252020-03-25T14:30:00.002+08:002020-05-05T04:22:11.484+08:00How To Create One Time Password Input | Android Studio & Java<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-igNHdyps1Nc/Xngc9CIX4AI/AAAAAAAABf8/6Y5zgu_3uz48ZTapdBvcF2G3--MjyKAsQCLcBGAsYHQ/s1600/OTP.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="720" data-original-width="1280" src="https://1.bp.blogspot.com/-igNHdyps1Nc/Xngc9CIX4AI/AAAAAAAABf8/6Y5zgu_3uz48ZTapdBvcF2G3--MjyKAsQCLcBGAsYHQ/s1600/OTP.jpg" /></a></div><br />
<br />
Hello guys, this tutorial I will make an OTP Online Time Password input. OTP is a verification code or a one-time password consisting of 6 unique (often numeric) secret characters that are generally sent via SMS or e-mail. Each code sent is generally only valid for 5 minutes.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Okay, first open your Android Studio, then open <b>build.gradle (module.app)</b> then add the following dependencies<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099; font-weight: bold;"><LinearLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">xmlns:app=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res-auto"</span>
<span style="color: #330099;">xmlns:tools=</span><span style="color: #cc3300;">"http://schemas.android.com/tools"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span>
<span style="color: #330099;">android:gravity=</span><span style="color: #cc3300;">"center_vertical"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"#0c0f18"</span>
<span style="color: #330099;">tools:context=</span><span style="color: #cc3300;">".MainActivity"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textAlignment=</span><span style="color: #cc3300;">"center"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">"MASUKKAN KODE VERIFIKASI"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#ffffff"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"30dp"</span>
<span style="color: #330099;">android:textStyle=</span><span style="color: #cc3300;">"bold"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"30dp"</span><span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><in.aabhasjindal.otptextview.OtpTextView</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/otp_view"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#ffffff"</span>
<span style="color: #330099;">app:height=</span><span style="color: #cc3300;">"90dp"</span>
<span style="color: #330099;">android:layout_gravity=</span><span style="color: #cc3300;">"center_horizontal"</span>
<span style="color: #330099;">app:width=</span><span style="color: #cc3300;">"50dp"</span>
<span style="color: #330099;">app:bar_enabled=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">app:bar_success_color=</span><span style="color: #cc3300;">"#43a047"</span>
<span style="color: #330099;">app:bar_active_color=</span><span style="color: #cc3300;">"#ffee58"</span>
<span style="color: #330099;">app:bar_height=</span><span style="color: #cc3300;">"2dp"</span>
<span style="color: #330099;">app:length=</span><span style="color: #cc3300;">"5"</span>
<span style="color: #330099;">app:otp_text_size=</span><span style="color: #cc3300;">"50dp"</span>
<span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"></LinearLayout></span>
</pre></div><br />
<br />
When it's finished the design will look like this<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-bZWioIGWhFg/Xngh7VME62I/AAAAAAAABg0/DHieEmR3Uu4ss00qcLV7TluEMIWvSRTVQCLcBGAsYHQ/s1600/otp2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="556" data-original-width="314" height="320" src="https://1.bp.blogspot.com/-bZWioIGWhFg/Xngh7VME62I/AAAAAAAABg0/DHieEmR3Uu4ss00qcLV7TluEMIWvSRTVQCLcBGAsYHQ/s320/otp2.png" width="180" /></a></div><br />
Next, we open <b>MainActivity.java</b> and enter the following code<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0em 0.0em 0.0em 0.0em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">androidx.appcompat.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">in.aabhasjindal.otptextview.OTPListener</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">in.aabhasjindal.otptextview.OtpTextView</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.Toast</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">class</span> <span style="color: #00aa88; font-weight: bold;">MainActivity</span> <span style="color: #006699; font-weight: bold;">extends</span> AppCompatActivity <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">private</span> OtpTextView otpTextView<span style="color: #555555;">;</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">protected</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">activity_main</span><span style="color: #555555;">);</span>
otpTextView <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">otp_view</span><span style="color: #555555;">);</span>
otpTextView<span style="color: #555555;">.</span><span style="color: #330099;">setOtpListener</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">new</span> OTPListener<span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onInteractionListener</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onOTPComplete</span><span style="color: #555555;">(</span>String otp<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">if</span> <span style="color: #555555;">(</span>otp<span style="color: #555555;">.</span><span style="color: #330099;">equals</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"12345"</span><span style="color: #555555;">)){</span>
otpTextView<span style="color: #555555;">.</span><span style="color: #330099;">showSuccess</span><span style="color: #555555;">();</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>MainActivity<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span><span style="color: #cc3300;">"Kode Verifikasi Benar "</span><span style="color: #555555;">+</span> otp<span style="color: #555555;">,</span> Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">else</span><span style="color: #555555;">{</span>
otpTextView<span style="color: #555555;">.</span><span style="color: #330099;">showError</span><span style="color: #555555;">();</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>MainActivity<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span><span style="color: #cc3300;">"Kode Verifikasi Salah"</span><span style="color: #555555;">,</span> Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">});</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
</pre></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
In the code above I make a condition if the OTP TextView type the number "12345" then the OTP code is declared correct, and if otherwise it is declared false. After all is done and there are no errors, the program is ready to run.<br />
<br />
Source Code : <a href="https://github.com/andiaspin/OTPAndroid" target="_blank">Github</a><br />
<br />
<br />
<iframe __idm_id__="493700097" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/0f6I-nSQ_Ic" width="100%"></iframe><br />
Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comtag:blogger.com,1999:blog-3825706424405165268.post-73367131915868597102020-03-04T13:07:00.001+08:002020-03-04T13:07:14.887+08:00Create Example Skill Progress Bar With HTML CSS<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-QDClowo9Z-0/W7F-shN0VRI/AAAAAAAABZM/Y6ilN8jhL7kD78vdDFm-ZFKOQLuBSrNQACEwYBhgL/s1600/PROGRESS%2BBAR.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="562" data-original-width="1000" src="https://2.bp.blogspot.com/-QDClowo9Z-0/W7F-shN0VRI/AAAAAAAABZM/Y6ilN8jhL7kD78vdDFm-ZFKOQLuBSrNQACEwYBhgL/s1600/PROGRESS%2BBAR.jpg" /></a></div><br />
<hr /><br />
Hello guys, this tutorial I will create a parameter of someone's expertise (individual) in the form of a progress bar horziontal. There are many types of progress bars that we can make, but this can also be a reference and inspiration for developers, especially beginners.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now, create a project folder and add the <b>index.html and style.css</b> files in it. If so, open <b>index.html</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Skill Progress Bar<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"center"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h1></span>Programming Language Skill<span style="color: #330099;"></h1></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skillbox"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><p></span>Python<span style="color: #330099;"></p></span>
<span style="color: #330099;"><p></span>95%<span style="color: #330099;"></p></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill_level"</span> <span style="color: #330099;">style=</span><span style="color: #cc3300;">"width: 95%"</span><span style="color: #330099;">></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skillbox"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><p></span>PHP<span style="color: #330099;"></p></span>
<span style="color: #330099;"><p></span>82%<span style="color: #330099;"></p></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill_level"</span> <span style="color: #330099;">style=</span><span style="color: #cc3300;">"width: 82%"</span><span style="color: #330099;">></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skillbox"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><p></span>Java<span style="color: #330099;"></p></span>
<span style="color: #330099;"><p></span>77%<span style="color: #330099;"></p></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill_level"</span> <span style="color: #330099;">style=</span><span style="color: #cc3300;">"width: 77%"</span><span style="color: #330099;">></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skillbox"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><p></span>SQL<span style="color: #330099;"></p></span>
<span style="color: #330099;"><p></span>56%<span style="color: #330099;"></p></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"skill_level"</span> <span style="color: #330099;">style=</span><span style="color: #cc3300;">"width: 56%"</span><span style="color: #330099;">></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre></div><br />
Next, open <b>style.css</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>
{
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#282828</span>;
}
<span style="color: #00aa88;">.center</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#333</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
box<span style="color: #555555;">-</span>shadow<span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">20px</span> <span style="color: #ff6600;">50px</span> rgba(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">5</span>);
}
<span style="color: #330099;">h1</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">2px</span>;
}
<span style="color: #00aa88;">.skillbox</span>{
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #00aa88;">.skillbox</span> <span style="color: #330099;">p</span>{
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #006699;">bold</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span>;
}
<span style="color: #00aa88;">.skillbox</span> <span style="color: #330099;">p</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">2</span><span style="color: #555555;">)</span>{
<span style="color: #006699;">float</span><span style="color: #555555;">:</span> <span style="color: #006699;">right</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">relative</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-25px</span>;
}
<span style="color: #00aa88;">.skill</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#282828</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">4px</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
<span style="color: #006699;">border</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#0fffb7</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">2px</span>;
}
<span style="color: #00aa88;">.skill_level</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#0fffb7</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
}</span>
</pre></div><br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndonesia-0.789275 113.921327-31.6684965 72.612733 30.0899465 155.229921tag:blogger.com,1999:blog-3825706424405165268.post-40483230973487977062020-02-24T23:34:00.001+08:002020-02-24T23:34:33.606+08:00Create Chat Group Using VB.Net<div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-XdR8hG7842k/Wy2dLOtRh0I/AAAAAAAABA8/7zXftUUUgQIOz4djXhbLHzDbEIn5MP9RQCLcBGAs/s1600/CHAT.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="667" data-original-width="1000" src="https://2.bp.blogspot.com/-XdR8hG7842k/Wy2dLOtRh0I/AAAAAAAABA8/7zXftUUUgQIOz4djXhbLHzDbEIn5MP9RQCLcBGAs/s1600/CHAT.jpg" /></a></div><br />
<br />
Hello friends, in this post I will discuss about how to create a simple chat group app that is connected on the same network, using Visual Studio IDE. Such an application is certainly very useful to exchange information, for example if two employees who want to communicate but the first employee is on the 1st floor while the other employees are on the 2nd floor. That's one example of the benefits of this kind of application and of course there are still benefits other.<br />
<br />
Now open and create a new project in Visual Studio, then design a form as server more or less as shown below<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-3OkbvJwMqVE/Wyxsgu7Q13I/AAAAAAAABAg/MIk4XwT6q340MffnK_VH7mwdN8E1pwJUwCLcBGAs/s1600/server.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="373" data-original-width="509" src="https://1.bp.blogspot.com/-3OkbvJwMqVE/Wyxsgu7Q13I/AAAAAAAABAg/MIk4XwT6q340MffnK_VH7mwdN8E1pwJUwCLcBGAs/s1600/server.png" /></a></div><br />
<div style="background-color: #ffffcc; border-left: 6px solid #ffeb3b; margin-bottom: 12px; padding: 12px 12px;"><strong> NOTES : </strong><br />
<br />
Componen Form Server :<br />
<ul><li>4 Label</li>
<li>2 TextBox</li>
<li>2 RichTextBox</li>
<li>1 Button</li>
<li>1 PictureBox</li>
</ul></div><br />
Next, create a new project again and design the form as a client more or less like in the picture below<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://4.bp.blogspot.com/-Ko3sMHUFiTw/WyxtXLZLqfI/AAAAAAAABAo/jDw_Aq1pKLMmkLWeDEqpQY3dQgHtJ-FsQCLcBGAs/s1600/CLIENT.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="413" data-original-width="387" src="https://4.bp.blogspot.com/-Ko3sMHUFiTw/WyxtXLZLqfI/AAAAAAAABAo/jDw_Aq1pKLMmkLWeDEqpQY3dQgHtJ-FsQCLcBGAs/s1600/CLIENT.png" /></a></div><br />
<div style="background-color: #ffffcc; border-left: 6px solid #ffeb3b; margin-bottom: 12px; padding: 12px 12px;"><strong> NOTES : </strong><br />
<br />
Componen Form Client :<br />
<ul><li>2 Label</li>
<li>3 TextBox</li>
<li>2 Button</li>
<li>1 RichTextBox</li>
</ul></div>Now, we go back to the project form server, then create a module and name it <b>CPcontrolClass</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net.Sockets</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Threading</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.IO</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">CPcontrolClass</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Event</span> MessageReceived(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> CPcontrolClass, <span style="color: #006699;">ByVal</span> Data <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">Public</span> serverIP <span style="color: black;">As</span> IPAddress <span style="color: #555555;">=</span> IPAddress.Parse(<span style="color: #cc3300;">"127.0.0.1"</span>)
<span style="color: #006699;">Public</span> serverPORT <span style="color: black;">As</span> <span style="color: #007788;">Integer</span> <span style="color: #555555;">=</span> <span style="color: #ff6600;">8080</span>
<span style="color: #006699;">Public</span> server <span style="color: black;">As</span> TcpListener
<span style="color: #006699;">Private</span> comThread <span style="color: black;">As</span> Thread
<span style="color: #006699;">Public</span> isListening <span style="color: black;">As</span> <span style="color: #007788;">Boolean</span> <span style="color: #555555;">=</span> <span style="color: #006699;">True</span>
<span style="color: #006699;">Private</span> client <span style="color: black;">As</span> TcpClient
<span style="color: #006699;">Private</span> clientData <span style="color: black;">As</span> StreamReader
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">New</span>()
server <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> TcpListener(serverIP, serverPORT)
server.Start()
comThread <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> Thread(<span style="color: #006699;">New</span> ThreadStart(<span style="color: black;">AddressOf</span> Listening))
comThread.Start()
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">ipnya</span>()
<span style="color: #006699;">Dim</span> addrs <span style="color: black;">As</span> IPAddress
<span style="color: #006699;">Dim</span> x <span style="color: black;">As</span> <span style="color: #007788;">Byte</span> <span style="color: #555555;">=</span> <span style="color: #ff6600;">0</span>
<span style="color: #006699;">Do</span>
addrs <span style="color: #555555;">=</span> Dns.GetHostEntry(Dns.GetHostName).AddressList(x)
x <span style="color: #555555;">+=</span> <span style="color: #ff6600;">1</span>
<span style="color: #006699;">Loop</span> Until (addrs.AddressFamily <span style="color: #555555;">=</span> AddressFamily.InterNetwork)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">Listening</span>()
<span style="color: #006699;">Do</span> Until isListening <span style="color: #555555;">=</span> <span style="color: #006699;">False</span>
<span style="color: #006699;">If</span> server.Pending <span style="color: #555555;">=</span> <span style="color: #006699;">True</span> <span style="color: #006699;">Then</span>
client <span style="color: #555555;">=</span> server.AcceptTcpClient
clientData <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> StreamReader(client.GetStream)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Try</span>
<span style="color: #006699;">RaiseEvent</span> MessageReceived(<span style="color: #006699;">Me</span>, clientData.ReadLine)
My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
<span style="color: #006699;">Catch</span> ex <span style="color: black;">As</span> Exception
<span style="color: #006699;">End</span> <span style="color: #006699;">Try</span>
Thread.Sleep(<span style="color: #ff6600;">100</span>)
<span style="color: #006699;">Loop</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Class</span></span>
</pre></div><br />
<div style="background-color: #ffffcc; border-left: 6px solid #ffeb3b; margin-bottom: 12px; padding: 12px 12px;"><strong> NOTES : </strong><br />
<br />
<b>127.0.0.1</b> is the local IP Address, if you want to use with a different device, please replace it with your device's ip address.<br />
<ul></ul></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
After that, import some of the required libraries on the server form<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net.Sockets</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Runtime.InteropServices</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Threading</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.IO</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">Form1</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Class</span></span>
</pre></div><br />
Then, declare some global variables<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">Form1</span>
<span style="color: #006699;">Private</span> server <span style="color: black;">As</span> CPcontrolClass
<span style="color: #006699;">Dim</span> log <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Dim</span> ipserver <span style="color: black;">As</span> IPAddress
<span style="color: #006699;">Private</span> TCPListener <span style="color: black;">As</span> TcpListener
<span style="color: #006699;">Private</span> clientCollection <span style="color: black;">As</span> <span style="color: #006699;">New</span> Hashtable()
<span style="color: #006699;">Private</span> usernameCollection <span style="color: black;">As</span> <span style="color: #006699;">New</span> Hashtable()
<span style="color: #006699;">Private</span> <span style="color: #006699;">Shared</span> connectID <span style="color: black;">As</span> <span style="color: #007788;">Long</span> <span style="color: #555555;">=</span> <span style="color: #ff6600;">0</span>
<span style="color: #006699;">Private</span> serverThread <span style="color: black;">As</span> Thread
<span style="color: #006699;">Public</span> <span style="color: #006699;">Delegate</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateListboxDelegate</span>(<span style="color: #006699;">ByVal</span> str <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">Dim</span> clientThread <span style="color: black;">As</span> System.Threading.Thread
<span style="color: #006699;">Dim</span> client <span style="color: black;">As</span> <span style="color: #006699;">New</span> TcpClient
<span style="color: #006699;">Dim</span> reader <span style="color: black;">As</span> BinaryReader
<span style="color: #006699;">Dim</span> writer <span style="color: black;">As</span> BinaryWriter
<span style="color: #006699;">Dim</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Dim</span> username <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Delegate</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateMessageDelegate</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">Delegate</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateUserDelegate</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">End</span> <span style="color: #006699;">Class</span></span>
</pre></div><br />
Then, create some of the following functions<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Public</span> <span style="color: #006699;">Structure</span> <span style="color: #00aa88;">ClientData</span>
<span style="color: #006699;">Public</span> structSocket <span style="color: black;">As</span> TcpClient
<span style="color: #006699;">Public</span> structThread <span style="color: black;">As</span> Thread
<span style="color: #006699;">Public</span> structReader <span style="color: black;">As</span> BinaryReader
<span style="color: #006699;">Public</span> structWriter <span style="color: black;">As</span> BinaryWriter
<span style="color: #006699;">End</span> <span style="color: #006699;">Structure</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateMessageWork</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
RichTextBox1.AppendText(message <span style="color: #555555;">+</span> vbNewLine)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateMessage</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">If</span> RichTextBox1.InvokeRequired <span style="color: #006699;">Then</span>
Invoke(<span style="color: #006699;">New</span> updateMessageDelegate(<span style="color: black;">AddressOf</span> updateMessageWork), message)
<span style="color: #006699;">Else</span>
RichTextBox1.AppendText(message <span style="color: #555555;">+</span> vbNewLine)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateUserWork</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">Dim</span> userlist() <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: #555555;">=</span> Split(message, Chr(<span style="color: #ff6600;">13</span>))
<span style="color: #006699;">Dim</span> i <span style="color: black;">As</span> <span style="color: #007788;">Integer</span>
lbUser.Items.Clear()
<span style="color: #006699;">For</span> i <span style="color: #555555;">=</span> <span style="color: #ff6600;">0</span> <span style="color: #006699;">To</span> userlist.Length <span style="color: #555555;">-</span> <span style="color: #ff6600;">1</span>
lbUser.Items.Add(userlist(i))
<span style="color: #006699;">Next</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateUser</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">If</span> lbUser.InvokeRequired <span style="color: #006699;">Then</span>
Invoke(<span style="color: #006699;">New</span> updateUserDelegate(<span style="color: black;">AddressOf</span> updateUserWork), message)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">readSocket</span>()
<span style="color: #006699;">Dim</span> realId <span style="color: black;">As</span> <span style="color: #007788;">Long</span> <span style="color: #555555;">=</span> connectID
<span style="color: #006699;">Dim</span> CData <span style="color: black;">As</span> <span style="color: #006699;">New</span> ClientData
CData <span style="color: #555555;">=</span> <span style="color: #006699;">CType</span>(clientCollection(realId), ClientData)
<span style="color: #006699;">Dim</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Dim</span> found <span style="color: black;">As</span> <span style="color: #007788;">Boolean</span> <span style="color: #555555;">=</span> <span style="color: #006699;">False</span>
<span style="color: #006699;">While</span> <span style="color: #006699;">True</span>
<span style="color: #006699;">If</span> CData.structSocket.Connected <span style="color: #006699;">Then</span>
<span style="color: #006699;">Try</span>
message <span style="color: #555555;">=</span> CData.structReader.ReadString()
<span style="color: #006699;">If</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"MES"</span> <span style="color: #006699;">Then</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> Client <span style="color: black;">As</span> ClientData <span style="color: black;">In</span> clientCollection.Values
<span style="color: #006699;">If</span> Client.structSocket.Connected <span style="color: #006699;">Then</span>
Client.structWriter.Write(message)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Next</span>
<span style="color: #006699;">ElseIf</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"USR"</span> <span style="color: #006699;">Then</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> user <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: black;">In</span> usernameCollection.Values()
<span style="color: #006699;">If</span> user <span style="color: #555555;">=</span> message.Substring(<span style="color: #ff6600;">4</span>) <span style="color: #006699;">Then</span>
found <span style="color: #555555;">=</span> <span style="color: #006699;">True</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Next</span>
<span style="color: #006699;">If</span> found <span style="color: #555555;">=</span> <span style="color: #006699;">True</span> <span style="color: #006699;">Then</span>
message <span style="color: #555555;">=</span> <span style="color: #cc3300;">"err"</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> Client <span style="color: black;">As</span> ClientData <span style="color: black;">In</span> clientCollection.Values()
<span style="color: #006699;">If</span> Client.structSocket.Connected <span style="color: #006699;">Then</span>
Client.structWriter.Write(message)
<span style="color: #006699;">Exit</span> <span style="color: #006699;">For</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Next</span>
<span style="color: #006699;">Try</span>
<span style="color: #006699;">Dim</span> client <span style="color: black;">As</span> ClientData <span style="color: #555555;">=</span> <span style="color: #006699;">CType</span>(clientCollection(realId), ClientData)
client.structThread.Abort()
<span style="color: #006699;">Catch</span> e <span style="color: black;">As</span> Exception
<span style="color: #006699;">SyncLock</span> <span style="color: #006699;">Me</span>
clientCollection.Remove(realId)
usernameCollection.Remove(realId)
<span style="color: #006699;">End</span> <span style="color: #006699;">SyncLock</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">Else</span>
usernameCollection.Add(realId, message.Substring(<span style="color: #ff6600;">4</span>))
<span style="color: #006699;">Dim</span> userlist <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> user <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: black;">In</span> usernameCollection.Values()
userlist <span style="color: #555555;">=</span> userlist <span style="color: #555555;">&</span> user <span style="color: #555555;">&</span> Chr(<span style="color: #ff6600;">13</span>)
<span style="color: #006699;">Next</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> Client <span style="color: black;">As</span> ClientData <span style="color: black;">In</span> clientCollection.Values()
<span style="color: #006699;">If</span> Client.structSocket.Connected <span style="color: #006699;">Then</span>
Client.structWriter.Write(<span style="color: #cc3300;">"USR "</span> <span style="color: #555555;">&</span> userlist)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Next</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">ElseIf</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"DIS"</span> <span style="color: #006699;">Then</span>
usernameCollection.Remove(realId)
<span style="color: #006699;">Dim</span> userlist <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> user <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: black;">In</span> usernameCollection.Values()
userlist <span style="color: #555555;">=</span> userlist <span style="color: #555555;">&</span> user <span style="color: #555555;">&</span> Chr(<span style="color: #ff6600;">13</span>)
<span style="color: #006699;">Next</span>
<span style="color: #006699;">For</span> <span style="color: #006699;">Each</span> Client <span style="color: black;">As</span> ClientData <span style="color: black;">In</span> clientCollection.Values()
<span style="color: #006699;">If</span> Client.structSocket.Connected <span style="color: #006699;">Then</span>
Client.structWriter.Write(<span style="color: #cc3300;">"USR "</span> <span style="color: #555555;">&</span> userlist)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Next</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Catch</span> e <span style="color: black;">As</span> Exception
<span style="color: #006699;">Exit</span> <span style="color: #006699;">While</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">While</span>
CloseTheThread(realId)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">CloseTheThread</span>(<span style="color: #006699;">ByVal</span> realId <span style="color: black;">As</span> <span style="color: #007788;">Long</span>)
<span style="color: #006699;">Try</span>
<span style="color: #006699;">Dim</span> client <span style="color: black;">As</span> ClientData <span style="color: #555555;">=</span> <span style="color: #006699;">CType</span>(clientCollection(realId), ClientData)
client.structThread.Abort()
<span style="color: #006699;">Catch</span> e <span style="color: black;">As</span> Exception
<span style="color: #006699;">SyncLock</span> <span style="color: #006699;">Me</span>
clientCollection.Remove(realId)
usernameCollection.Remove(realId)
<span style="color: #006699;">End</span> <span style="color: #006699;">SyncLock</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">OnlineReceived</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> CPcontrolClass, <span style="color: #006699;">ByVal</span> Data <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">readSocketClient</span>()
<span style="color: #006699;">While</span> <span style="color: #006699;">True</span>
<span style="color: #006699;">Try</span>
message <span style="color: #555555;">=</span> reader.ReadString()
<span style="color: #006699;">If</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"MES"</span> <span style="color: #006699;">Then</span>
updateMessage(message.Substring(<span style="color: #ff6600;">4</span>))
<span style="color: #006699;">ElseIf</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"USR"</span> <span style="color: #006699;">Then</span>
updateUser(message.Substring(<span style="color: #ff6600;">4</span>))
<span style="color: #006699;">ElseIf</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"DIS"</span> <span style="color: #006699;">Then</span>
updateUser(message.Substring(<span style="color: #ff6600;">4</span>))
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> message <span style="color: #555555;">=</span> <span style="color: #cc3300;">"err"</span> <span style="color: #006699;">Then</span>
<span style="color: #006699;">Exit</span> <span style="color: #006699;">Sub</span>
<span style="color: #cc00ff;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Catch</span> e <span style="color: black;">As</span> Exception
<span style="color: #006699;">Exit</span> <span style="color: #006699;">While</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">While</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">writeSocket</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">If</span> client.Connected <span style="color: #006699;">Then</span>
writer.Write(message)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">startConnect</span>()
<span style="color: #006699;">Try</span>
client <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> TcpClient()
client.Connect(ipserver, <span style="color: #ff6600;">8888</span>)
reader <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> BinaryReader(client.GetStream())
writer <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> BinaryWriter(client.GetStream())
writer.Write(<span style="color: #cc3300;">"USR "</span> <span style="color: #555555;">+</span> TextBox1.Text)
username <span style="color: #555555;">=</span> TextBox1.Text
clientThread <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> System.Threading.Thread(<span style="color: black;">AddressOf</span> readSocketClient)
clientThread.Start()
server <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> CPcontrolClass
<span style="color: #006699;">AddHandler</span> server.MessageReceived, <span style="color: black;">AddressOf</span> OnlineReceived
RichTextBox1.Visible <span style="color: #555555;">=</span> <span style="color: #006699;">True</span>
lbUser.Visible <span style="color: #555555;">=</span> <span style="color: #006699;">True</span>
<span style="color: #006699;">Catch</span> ex <span style="color: black;">As</span> Exception
<span style="color: #006699;">Exit</span> <span style="color: #006699;">Sub</span>
<span style="color: #cc00ff;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">New</span>()
InitializeComponent()
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">waitingForClient</span>()
<span style="color: #006699;">Dim</span> CData <span style="color: black;">As</span> <span style="color: #006699;">New</span> ClientData
<span style="color: #006699;">While</span> <span style="color: #006699;">True</span>
CData.structSocket <span style="color: #555555;">=</span> TCPListener.AcceptTcpClient
Interlocked.Increment(connectID)
CData.structThread <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> Thread(<span style="color: black;">AddressOf</span> readSocket)
CData.structReader <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> BinaryReader(CData.structSocket.GetStream())
CData.structWriter <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> BinaryWriter(CData.structSocket.GetStream())
<span style="color: #006699;">SyncLock</span> <span style="color: #006699;">Me</span>
clientCollection.Add(connectID, CData)
<span style="color: #006699;">End</span> <span style="color: #006699;">SyncLock</span>
CData.structThread.Start()
<span style="color: #006699;">End</span> <span style="color: #006699;">While</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre></div><br />
Then, double-click Button1 and enter the following code<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">Button1_Click</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.EventArgs) <span style="color: #006699;">Handles</span> Button1.Click
<span style="color: #006699;">If</span> TextBox1.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span> <span style="color: black;">Or</span> TextBox3.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span> <span style="color: #006699;">Then</span>
MsgBox(<span style="color: #cc3300;">"please complete the field"</span>, MsgBoxStyle.Exclamation)
<span style="color: #006699;">Else</span>
<span style="color: #006699;">Dim</span> addr <span style="color: black;">As</span> IPAddress <span style="color: #555555;">=</span> IPAddress.Parse(TextBox3.Text)
ipserver <span style="color: #555555;">=</span> addr
TCPListener <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> TcpListener(addr, <span style="color: #ff6600;">8888</span>)
TCPListener.Start()
serverThread <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> Thread(<span style="color: black;">AddressOf</span> waitingForClient)
serverThread.Start()
startConnect()
MsgBox(<span style="color: #cc3300;">"Connection Successful As "</span> <span style="color: #555555;">+</span> TextBox1.Text, MsgBoxStyle.Information)
TextBox1.Clear()
TextBox3.Clear()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Next, enter the following code in the Form_Closing event<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">Form1_FormClosing</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.Windows.Forms.FormClosingEventArgs) <span style="color: #006699;">Handles</span> <span style="color: #006699;">MyBase</span>.FormClosing
writeSocket(<span style="color: #cc3300;">"DIS:"</span>)
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (clientThread <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
<span style="color: #006699;">If</span> clientThread.IsAlive <span style="color: #006699;">Then</span> clientThread.Abort()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (reader <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
reader.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (writer <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
writer.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (client <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
client.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Me</span>.Dispose()
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre></div><br />
Now, we have finished on the server part, now we move on client project. Same as server, create a module and name it <b>TCPcontroller</b>, then enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.IO</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net.Sockets</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">TCPcontroller</span>
<span style="color: #006699;">Public</span> client <span style="color: black;">As</span> TcpClient
<span style="color: #006699;">Public</span> clientData <span style="color: black;">As</span> StreamWriter
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">New</span>(<span style="color: #006699;">ByVal</span> Host <span style="color: black;">As</span> <span style="color: #007788;">String</span>, <span style="color: #006699;">ByVal</span> Port <span style="color: black;">As</span> <span style="color: #007788;">Integer</span>)
<span style="color: #006699;">On</span> <span style="color: #006699;">Error</span> <span style="color: #006699;">Resume</span> <span style="color: #006699;">Next</span>
client <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> TcpClient(Host, Port)
clientData <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> StreamWriter(client.GetStream)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">send</span>(<span style="color: #006699;">ByVal</span> Data <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">On</span> <span style="color: #006699;">Error</span> <span style="color: #006699;">Resume</span> <span style="color: #006699;">Next</span>
clientData.Write(Data <span style="color: #555555;">&</span> vbCrLf)
clientData.Flush()
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Class</span></span>
</pre></div><br />
Next, go to the form section, then import some of the required libraries<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Drawing.Text</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net.Sockets</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Text</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.IO</span>
<span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Net</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">Form1</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Class</span></span>
</pre></div><br />
Then, declare the following global variables<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">Form1</span>
<span style="color: #006699;">Private</span> <span style="color: #006699;">Declare</span> <span style="color: #006699;">Function</span> <span style="color: #cc00ff;">mciSendString</span> <span style="color: #006699;">Lib</span> <span style="color: #cc3300;">"winmm.dll"</span> <span style="color: #006699;">Alias</span> <span style="color: #cc3300;">"mciSendStringA"</span> (<span style="color: #006699;">ByVal</span> lpstrCommand <span style="color: black;">As</span> <span style="color: #007788;">String</span>, <span style="color: #006699;">ByVal</span> lpstrReturnString <span style="color: black;">As</span>
<span style="color: #007788;">String</span>, <span style="color: #006699;">ByVal</span> uReturnLength <span style="color: black;">As</span> <span style="color: #007788;">Integer</span>, <span style="color: #006699;">ByVal</span> hwndCallback <span style="color: black;">As</span> <span style="color: #007788;">Integer</span>) <span style="color: black;">As</span> <span style="color: #007788;">Integer</span>
<span style="color: #006699;">Private</span> clientnya <span style="color: black;">As</span> TCPcontroller
<span style="color: #006699;">Dim</span> FileName <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Dim</span> pfc <span style="color: black;">As</span> <span style="color: #006699;">New</span> PrivateFontCollection()
<span style="color: #006699;">Dim</span> status <span style="color: black;">As</span> <span style="color: #007788;">Byte</span>
<span style="color: #006699;">Dim</span> clientThread <span style="color: black;">As</span> System.Threading.Thread
<span style="color: #006699;">Dim</span> client <span style="color: black;">As</span> <span style="color: #006699;">New</span> TcpClient
<span style="color: #006699;">Dim</span> screen <span style="color: black;">As</span> Screen
<span style="color: #006699;">Dim</span> reader <span style="color: black;">As</span> BinaryReader
<span style="color: #006699;">Dim</span> writer <span style="color: black;">As</span> BinaryWriter
<span style="color: #006699;">Dim</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Dim</span> username <span style="color: black;">As</span> <span style="color: #007788;">String</span>
<span style="color: #006699;">Delegate</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateMessageDelegate</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">End</span> <span style="color: #006699;">Class</span></span>
</pre></div><br />
Then, make some of the following functions<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateMessageWork</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
RichTextBox1.AppendText(message <span style="color: #555555;">+</span> vbNewLine)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">updateMessage</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">If</span> RichTextBox1.InvokeRequired <span style="color: #006699;">Then</span>
Invoke(<span style="color: #006699;">New</span> updateMessageDelegate(<span style="color: black;">AddressOf</span> updateMessageWork), message)
<span style="color: #006699;">Else</span>
RichTextBox1.AppendText(message <span style="color: #555555;">+</span> vbNewLine)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">startConnect</span>()
<span style="color: #006699;">Try</span>
client <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> TcpClient()
client.Connect(IPAddress.Parse(TextBox3.Text), <span style="color: #ff6600;">8888</span>)
reader <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> BinaryReader(client.GetStream())
writer <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> BinaryWriter(client.GetStream())
writer.Write(<span style="color: #cc3300;">"USR "</span> <span style="color: #555555;">&</span> TextBox2.Text)
username <span style="color: #555555;">=</span> TextBox2.Text
clientThread <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> System.Threading.Thread(<span style="color: black;">AddressOf</span> readSocketClient)
clientThread.Start()
<span style="color: #006699;">Catch</span> ex <span style="color: black;">As</span> Exception
<span style="color: #006699;">Exit</span> <span style="color: #006699;">Sub</span>
<span style="color: #cc00ff;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">readSocketClient</span>()
<span style="color: #006699;">While</span> <span style="color: #006699;">True</span>
<span style="color: #006699;">Try</span>
message <span style="color: #555555;">=</span> reader.ReadString()
<span style="color: #006699;">If</span> message.Substring(<span style="color: #ff6600;">0</span>, <span style="color: #ff6600;">3</span>) <span style="color: #555555;">=</span> <span style="color: #cc3300;">"MES"</span> <span style="color: #006699;">Then</span>
updateMessage(message.Substring(<span style="color: #ff6600;">4</span>))
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> message <span style="color: #555555;">=</span> <span style="color: #cc3300;">"err"</span> <span style="color: #006699;">Then</span>
MsgBox(<span style="color: #cc3300;">"Problem Connection"</span>, MsgBoxStyle.Information, <span style="color: #cc3300;">"Information"</span>)
message <span style="color: #555555;">=</span> reader.ReadString()
<span style="color: #006699;">End</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Catch</span> e <span style="color: black;">As</span> Exception
<span style="color: #006699;">Exit</span> <span style="color: #006699;">While</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">While</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">writeSocket</span>(<span style="color: #006699;">ByVal</span> message <span style="color: black;">As</span> <span style="color: #007788;">String</span>)
<span style="color: #006699;">Try</span>
<span style="color: #006699;">If</span> client.Connected <span style="color: #006699;">Then</span>
writer.Write(message)
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Catch</span> ex <span style="color: black;">As</span> Exception
<span style="color: #006699;">Exit</span> <span style="color: #006699;">Sub</span>
<span style="color: #cc00ff;">End</span> <span style="color: #006699;">Try</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre></div><br />
Next, double-click the Sign In Button and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">ButtonSignIn_Click</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.EventArgs) <span style="color: #006699;">Handles</span> ButtonSignIn.Click
<span style="color: #006699;">If</span> ButtonSignIn.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">"SIGN IN"</span> <span style="color: #006699;">Then</span>
<span style="color: #006699;">If</span> TextBox2.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span> <span style="color: black;">Or</span> TextBox3.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span> <span style="color: #006699;">Then</span>
MsgBox(<span style="color: #cc3300;">"please complete all fields"</span>, MsgBoxStyle.Exclamation)
<span style="color: #006699;">Else</span>
clientnya <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> TCPcontroller(TextBox3.Text, <span style="color: #ff6600;">8080</span>)
startConnect()
ButtonSignIn.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">"SIGN OUT"</span>
ButtonSignIn.FlatAppearance.MouseOverBackColor <span style="color: #555555;">=</span> Color.Red
MsgBox(<span style="color: #cc3300;">"You Are Connected As "</span> <span style="color: #555555;">+</span> TextBox2.Text, MsgBoxStyle.Information)
TextBox2.Clear()
TextBox3.Clear()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">Else</span>
writeSocket(<span style="color: #cc3300;">"DIS:"</span>)
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (clientThread <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
<span style="color: #006699;">If</span> clientThread.IsAlive <span style="color: #006699;">Then</span> clientThread.Abort()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (reader <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
reader.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (writer <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
writer.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (client <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
</span> client.Close()
<span style="font-family: "courier new" , "courier" , monospace;"> <span style="color: #006699; font-weight: bold;">End</span> <span style="color: #006699; font-weight: bold;">If</span>
MsgBox(<span style="color: #cc3300;">"You Sign Out"</span>, MsgBoxStyle.Information)
ButtonSignIn.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">"SIGN IN"</span>
ButtonSignIn.FlatAppearance.MouseOverBackColor <span style="color: #555555;">=</span> Color.Green
<span style="color: #006699; font-weight: bold;">End</span> <span style="color: #006699; font-weight: bold;">If</span>
<span style="color: #006699; font-weight: bold;">End</span> <span style="color: #006699; font-weight: bold;">Sub</span></span>
</pre></div><br />
Next, double-click the send button and enter the following code<br />
<br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">ButtonSent_Click</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.EventArgs) <span style="color: #006699;">Handles</span> ButtonSent.Click
<span style="color: #006699;">If</span> ButtonSent.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">"SIGN IN"</span> <span style="color: #006699;">Then</span>
MsgBox(<span style="color: #cc3300;">"You Must Sign In First"</span>, MessageBoxIcon.Exclamation)
<span style="color: #006699;">Else</span>
<span style="color: #006699;">If</span> TextBox1.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span> <span style="color: #006699;">Then</span>
MsgBox(<span style="color: #cc3300;">"Message Can not Empty."</span>, MessageBoxIcon.Exclamation)
<span style="color: #006699;">Else</span>
writeSocket(<span style="color: #cc3300;">"MES:"</span> <span style="color: #555555;">&</span> username <span style="color: #555555;">&</span> <span style="color: #cc3300;">" : "</span> <span style="color: #555555;">&</span> TextBox1.Text)
TextBox1.Text <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span>
TextBox1.Focus()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
and finally, enter the following code in the Form_Closing event<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.0 0.1em 0.0 0.1em 0.0 0.1em 0.0 0.1em; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">Form1_FormClosing</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.Windows.Forms.FormClosingEventArgs) <span style="color: #006699;">Handles</span> <span style="color: #006699;">MyBase</span>.FormClosing
writeSocket(<span style="color: #cc3300;">"DIS:"</span>)
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (clientThread <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
<span style="color: #006699;">If</span> clientThread.IsAlive <span style="color: #006699;">Then</span> clientThread.Abort()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (reader <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
reader.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (writer <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
writer.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">If</span> <span style="color: #006699;">Not</span> (client <span style="color: black;">Is</span> <span style="color: #006699;">Nothing</span>) <span style="color: #006699;">Then</span>
client.Close()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
Dispose()
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre></div><br />
Up here, the program is ready to run using one device. If you want to use multiple devices, do not forget to change the IP Address of the device you want to use<br />
<br />
<h3>For more details, please watch the video below</h3><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/JzUHV7J1I-8/0.jpg" frameborder="0" height="370" src="https://www.youtube.com/embed/JzUHV7J1I-8?feature=player_embedded" width="100%"></iframe></div><br />
Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndonesia-0.789275 113.921327-31.6684965 72.612733 30.0899465 155.229921tag:blogger.com,1999:blog-3825706424405165268.post-43376815875001029622020-01-13T23:08:00.000+08:002020-04-03T16:36:48.658+08:00How To Open Pdf in Android Studio<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-_-fZ6cFeczM/XhyGg11JJjI/AAAAAAAABfQ/sWMBhXn8NJERnpFDcvLJldYxCVAqyypVQCLcBGAsYHQ/s1600/pdf-mobile-apps.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="430" data-original-width="650" src="https://1.bp.blogspot.com/-_-fZ6cFeczM/XhyGg11JJjI/AAAAAAAABfQ/sWMBhXn8NJERnpFDcvLJldYxCVAqyypVQCLcBGAsYHQ/s1600/pdf-mobile-apps.jpg" /></a></div>
<br />
Pdf is a file type that is very popular today, where every article or other text work that we have worked on can be converted into a file with pdf extension so that readers can be more flexible in reading our work, especially on the Android platform.</div>
<div>
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
So, in this post I will discuss how to display PDF files on Android Studio. As usual, create a new project. then add the Assets folder<br />
<br />
<b>Right-click the project > New > Folder > Folder Assets</b></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-Izk3yEJAE1o/W3upd-MB9rI/AAAAAAAABJY/-MGsXzL732UQVP36czaYRif8cEcX_j2jQCLcBGAs/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="572" data-original-width="762" src="https://4.bp.blogspot.com/-Izk3yEJAE1o/W3upd-MB9rI/AAAAAAAABJY/-MGsXzL732UQVP36czaYRif8cEcX_j2jQCLcBGAs/s1600/1.jpg" /></a></div>
<div>
<br /></div>
<div>
Then, in the Assets folder you save your PDF file</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-xkaK4DI-QMM/W3uqbJThYMI/AAAAAAAABJg/bwbMJLFmvDQKiA3Xwp_prDR764e7_x-mwCLcBGAs/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="220" data-original-width="682" src="https://3.bp.blogspot.com/-xkaK4DI-QMM/W3uqbJThYMI/AAAAAAAABJg/bwbMJLFmvDQKiA3Xwp_prDR764e7_x-mwCLcBGAs/s1600/2.jpg" /></a></div>
<div>
<br /></div>
<div>
After that, open <b>build.gradle</b> then enter the following library</div>
<div>
<br /></div>
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">dependencies</span> {
compile fileTree(dir<span style="color: #555555;">:</span> <span style="color: #cc3300;">'libs'</span><span style="color: #555555;">,</span> include<span style="color: #555555;">:</span> [<span style="color: #cc3300;">'*.jar'</span>])
testCompile <span style="color: #cc3300;">'junit:junit:4.12'</span>
compile <span style="color: #cc3300;">'com.android.support:appcompat-v7:23.4.0'</span>
compile <span style="color: #cc3300;">'com.android.support:design:23.4.0'</span>
compile <span style="color: #cc3300;">'com.github.barteksc:android-pdf-viewer:2.7.0'</span>
}</span>
</pre>
</div>
<br />
When finished, open <b>activity_main.xml</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><RelativeLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><com.github.barteksc.pdfviewer.PDFView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/pdfView"</span>
<span style="color: #330099;">android:layout_above=</span><span style="color: #cc3300;">"@+id/btn"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span><span style="color: #330099;">/></span>
<span style="color: #330099;"><Button</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/btn"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">"LOAD PDF"</span>
<span style="color: #330099;">android:layout_centerHorizontal=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_alignParentBottom=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"></RelativeLayout></span></span>
</pre>
</div>
<br />
Now, we open <b>MainActivity.java</b> then enter the following code to display the Pdf file when the "LOAD PDF" button is clicked<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v7.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.Button</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">com.github.barteksc.pdfviewer.PDFView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MainActivity</span> <span style="color: #006699;">extends</span> AppCompatActivity <span style="color: #555555;">{</span>
PDFView pdfView<span style="color: #555555;">;</span>
Button btn<span style="color: #555555;">;</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">protected</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">activity_main</span><span style="color: #555555;">);</span>
pdfView <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>PDFView<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">pdfView</span><span style="color: #555555;">);</span>
btn <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>Button<span style="color: #555555;">)</span>findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">btn</span><span style="color: #555555;">);</span>
btn<span style="color: #555555;">.</span><span style="color: #330099;">setOnClickListener</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> View<span style="color: #555555;">.</span><span style="color: #330099;">OnClickListener</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onClick</span><span style="color: #555555;">(</span>View v<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
pdfView<span style="color: #555555;">.</span><span style="color: #330099;">fromAsset</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"visualbasic.pdf"</span><span style="color: #555555;">).</span><span style="color: #330099;">load</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">});</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre>
</div>
<br />
When it's finished, the program is ready to run.Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndonesia-0.789275 113.92132700000002-31.6684965 72.61273300000002 30.0899465 155.22992100000002tag:blogger.com,1999:blog-3825706424405165268.post-21246520888013675902020-01-03T19:22:00.002+08:002021-02-20T21:25:34.474+08:00Program Parkir Sederhana Menggunakan QR Code<amp-auto-ads type="adsense"
data-ad-client="ca-pub-5403872783527179">
</amp-auto-ads>
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-tDjNt6xeTBI/XgyxAso1WCI/AAAAAAAABeI/v0xH8rvEfkoinyFqjbioDT5w6gT4MQmiACPcBGAYYCw/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="907" data-original-width="1600" src="https://1.bp.blogspot.com/-tDjNt6xeTBI/XgyxAso1WCI/AAAAAAAABeI/v0xH8rvEfkoinyFqjbioDT5w6gT4MQmiACPcBGAYYCw/s1600/3.png" /></a></div><br />
<br />
Halo guys, tutorial kali ini membahas tentang cara membuat sebuah aplikasi parkir sederhana berbasis web dan android. Jadi, skenarionya adalah pengunjung masuk dan bertemu dengan petugas gerbang masuk, lalu petugas mencatat data kendaraan lalu memberikan struk dengan pola QR Code yang nantinya diberikan kepada petugas gerbang keluar untuk proses pemindaian.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Adapun bahasa pemrograman yang dipakai untuk aplikasi berbasis web adalah PHP dan aplikasi pemrograman android menggunakan java, yang keduanya terhubung dalam satu database yaitu MySQL. Selanjutnya kita buat database terlebih dahulu sebagai contoh saya membuat database dengan nama <b>"barcode_park"</b> dengan satu tabel dengan nama <b>"parkir"</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-aAolRcrXjYU/Xgx5KG9E7oI/AAAAAAAABdU/1NjSjYqb8XQAHWhUmlDqbKS6vV9aEKngACLcBGAsYHQ/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="302" data-original-width="973" src="https://1.bp.blogspot.com/-aAolRcrXjYU/Xgx5KG9E7oI/AAAAAAAABdU/1NjSjYqb8XQAHWhUmlDqbKS6vV9aEKngACLcBGAsYHQ/s1600/1.png" /></a></div><br />
<br />
<ul><li>id_parkir (int : autoincreament)</li>
<li>KodeBarcode : varchar</li>
<li>Jenis : varchar</li>
<li>Merek : varchar</li>
<li>Warna : varchar</li>
<li>Plat : varchar</li>
<li>JamMasuk : DateTime</li>
<li>JamKeluar : DateTime</li>
</ul><div>jika databasenya sudah siap, sekarang siapkan sebuah folder project didalam directory kamu. sebagai contoh saya disini saya beri nama "<b>parkir</b>" didalamnya terdapat 2 file utama yaitu <b>aksi.php </b>dan <b>index.php</b> selebihnya merupakan folder pendukung lainnya. </div><div><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-nXAUCxqZTiQ/XgytF2K7nDI/AAAAAAAABds/CoZMeafrUTYm4_FzIISEcGhjGuj3t_4iACLcBGAsYHQ/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="367" data-original-width="817" src="https://1.bp.blogspot.com/-nXAUCxqZTiQ/XgytF2K7nDI/AAAAAAAABds/CoZMeafrUTYm4_FzIISEcGhjGuj3t_4iACLcBGAsYHQ/s1600/2.png" /></a></div><div><br />
</div><div>Folder "temp" merupakan tempat menyimpan gambar QR Code setelah menyimpan data kendaraan yang masuk. Selanjutnya buka file <b>index.php</b> lalu masukkan kode berikut</div><br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><!DOCTYPE html>
<span style="color: #009999;"><?php</span>
<span style="color: #006699; font-weight: bold;">function</span> <span style="color: #cc00ff;">autonumber</span>(<span style="color: #003333;">$tabel</span> ,<span style="color: #003333;">$kolom</span>, <span style="color: #003333;">$lebar</span><span style="color: #555555;">=</span><span style="color: #ff6600;">0</span>, <span style="color: #003333;">$awalan</span><span style="color: #555555;">=</span><span style="color: #cc3300;">''</span>){
<span style="color: #003333;">$host</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"localhost"</span>;
<span style="color: #003333;">$usr</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"youruser"</span>;
<span style="color: #003333;">$pwd</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"yourpasswrod"</span>;
<span style="color: #003333;">$dbname</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"barcode_park"</span>;
<span style="color: #003333;">$koneksi</span> <span style="color: #555555;">=</span> <span style="color: #336666;">mysqli_connect</span>(<span style="color: #003333;">$host</span>, <span style="color: #003333;">$usr</span>, <span style="color: #003333;">$pwd</span>, <span style="color: #003333;">$dbname</span>);
<span style="color: #006699; font-weight: bold;">if</span>(mysqli_connect_error()){
<span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #cc3300;">'database gagal dikoneksikan!'</span><span style="color: #555555;">.</span>mysqli_connect_error();
}
<span style="color: #0099ff; font-style: italic;">//proses auto number</span>
<span style="color: #003333;">$auto</span> <span style="color: #555555;">=</span> mysqli_query(<span style="color: #003333;">$koneksi</span>, <span style="color: #cc3300;">"select </span><span style="color: #aa0000;">$kolom</span><span style="color: #cc3300;"> from </span><span style="color: #aa0000;">$tabel</span><span style="color: #cc3300;"> order by </span><span style="color: #aa0000;">$kolom</span><span style="color: #cc3300;"> desc limit 1"</span>) <span style="color: #006699; font-weight: bold;">or</span> <span style="color: #006699; font-weight: bold;">die</span>(mysqli_error());
<span style="color: #003333;">$jumlah_record</span> <span style="color: #555555;">=</span> mysqli_num_rows(<span style="color: #003333;">$auto</span>);
<span style="color: #006699; font-weight: bold;">if</span>(<span style="color: #003333;">$jumlah_record</span> <span style="color: #555555;">==</span> <span style="color: #ff6600;">0</span>)
<span style="color: #003333;">$nomor</span> <span style="color: #555555;">=</span> <span style="color: #ff6600;">1</span>;
<span style="color: #006699; font-weight: bold;">else</span>{
<span style="color: #003333;">$row</span> <span style="color: #555555;">=</span> mysqli_fetch_array(<span style="color: #003333;">$auto</span>);
<span style="color: #003333;">$nomor</span> <span style="color: #555555;">=</span> <span style="color: #336666;">intval</span>(substr(<span style="color: #003333;">$row</span>[<span style="color: #ff6600;">0</span>], <span style="color: #336666;">strlen</span>(<span style="color: #003333;">$awalan</span>)))<span style="color: #555555;">+</span><span style="color: #ff6600;">1</span>;
}
<span style="color: #006699; font-weight: bold;">if</span>(<span style="color: #003333;">$lebar</span><span style="color: #555555;">></span><span style="color: #ff6600;">0</span>)
<span style="color: #003333;">$angka</span> <span style="color: #555555;">=</span> <span style="color: #003333;">$awalan</span><span style="color: #555555;">.</span><span style="color: #336666;">str_pad</span> (<span style="color: #003333;">$nomor</span>, <span style="color: #003333;">$lebar</span>, <span style="color: #cc3300;">"0"</span>, STR_PAD_LEFT);
<span style="color: #006699; font-weight: bold;">else</span>
<span style="color: #003333;">$angka</span><span style="color: #555555;">=</span><span style="color: #003333;">$awalan</span><span style="color: #555555;">.</span><span style="color: #003333;">$nomor</span>;
<span style="color: #006699; font-weight: bold;">return</span> <span style="color: #003333;">$angka</span>;
}
<span style="color: #009999;">?></span>
<html lang="en">
<head>
<title>Aplikasi Parkir</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/icons/favicon.ico" />
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
<style>
.page1 {
width: 100%;
height: 100%;
}
.page2 {
width: 100%;
height: 100%;
position: relative;
margin: 0;
background: crimson; /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #3498db, #2c3e50); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #3498db, #2c3e50); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
font-family: sans-serif;
font-weight: 100;
}
.container-contact1 {
width: 800px;
padding: 32px;
}
.form-control {
display: block;
width: 100%;
padding: 0 30px;
font-size: 15px;
line-height: 1.25;
color: #495057;
background-color: #fff;
background-image: none;
background-clip: padding-box;
border: 1px solid rgba(0, 0, 0, .15);
border-radius: 25px;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
margin-bottom: 25px;
font-family: Montserrat-Bold;
height: 50px;
}
.page2.containerr {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.fixed_header {
width: 85%;
height: auto;
}
.fixed_header tbody {
display: block;
width: 100%;
overflow: auto;
height: 400px;
}
.fixed_header thead tr {
display: block;
}
.fixed_header thead {
background: black;
color: #fff;
}
.fixed_header th,
.fixed_header td {
padding: 10x;
text-align: left;
width: 200px;
}
table {
width: 75%;
border-collapse: collapse;
overflow: auto;
table-layout: fixed;
border-collapse: collapse;
position: absolute;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.32);
top: 55%;
left: 50%;
transform: translate(-50%, -50%);
}
th,
td {
padding: 15px;
background-color: rgba(255, 255, 255, 0);
color: #fff;
}
th {
text-align: left;
}
thead {
th {
background-color: #55608f;
}
}
tbody {
tr {
&:hover {
background-color: rgba(255, 255, 255, 0.3);
}
}
td {
position: relative;
&:hover {
&:before {
content: "";
position: absolute;
left: 0;
right: 0;
top: -9999px;
bottom: -9999px;
background-color: rgba(255, 255, 255, 0.2);
z-index: -1;
}
}
}
}
.contact1-form-titlee {
display: block;
position: absolute;
font-family: Montserrat-ExtraBold;
font-size: 47px;
color: #f5f5f5;
line-height: 1.2;
text-align: center;
text-shadow: 2px 2px #000000b3;
padding-bottom: 44px;
top: 20%;
left: 50%;
transform: translate(-50%, -50%)
}
.contact1-form-titleee {
display: block;
font-family: Montserrat-ExtraBold;
font-size: 30px;
color: #f5f5f5;
line-height: 1.2;
text-shadow: 2px 2px #000000b3;
text-align: center;
padding-bottom: 44px;
}
</style>
</head>
<body>
<div class="page1">
<div class="contact1">
<div class="container-contact1">
<div class="contact1-pic js-tilt" data-tilt>
<img src="images/com.png" alt="IMG">
</div>
<form class="contact1-form validate-form" method="POST" action="aksi.php">
<span class="contact1-form-titleee">
Data Kendaraan
</span>
<div class="wrap-input1 validate-input">
<input class="input1" type="text" name="KodeBarcode" placeholder="Kode Barcode" value="<span style="color: #009999;"><?</span><span style="color: #555555;">=</span> autonumber(<span style="color: #cc3300;">" parkir "</span>, <span style="color: #cc3300;">"KodeBarcode "</span>, <span style="color: #cc3300;">"4 "</span>, <span style="color: #cc3300;">"PARK-"</span>) <span style="color: #009999;">?></span> " readonly>
<span class="shadow-input1"></span>
</div>
<div class="wrap-input1 validate-input" data-validate="Valid email is required: ex@abc.xyz">
<input onkeyup="this.value = this.value.toUpperCase()"; class="input1" type="text" name="plat" placeholder="Nomor Polisi" required oninvalid="this.setCustomValidity('Plat Belum Diisi')" oninput="this.setCustomValidity('')">
<span class="shadow-input1"></span>
</div>
<div class="wrap-input1 validate-input" data-validate="Subject is required">
<input onkeyup="this.value = this.value.toUpperCase()"; class="input1" type="text" name="merek" placeholder="Merek" required oninvalid="this.setCustomValidity('Merek Belum Diisi')" oninput="this.setCustomValidity('')">
<span class="shadow-input1"></span>
</div>
<div class="wrap-input1 validate-input" data-validate="Subject is required">
<input onkeyup="this.value = this.value.toUpperCase()"; class="input1" type="text" name="warna" placeholder="Warna" required oninvalid="this.setCustomValidity('Warna Belum Diisi')" oninput="this.setCustomValidity('')">
<span class="shadow-input1"></span>
</div>
<select class="form-control" name="jenis">
<option value="MOBIL">MOBIL</option>
<option value="MOTOR">MOTOR</option>
</select>
<div class="container-contact1-form-btn">
<input type="submit" class="contact1-form-btn" value="Simpan">
</div>
</form>
</div>
</div>
</div>
<div class="page2" id="dataParkir">
<span style="color: #009999;"><?php</span>
<span style="color: #003333;">$koneksinya</span> <span style="color: #555555;">=</span> <span style="color: #336666;">mysqli_connect</span>(<span style="color: #cc3300;">"localhost"</span>,<span style="color: #cc3300;">"youruser"</span>,<span style="color: #cc3300;">"yourpwd"</span>,<span style="color: #cc3300;">"Barcode_Park"</span>) <span style="color: #006699; font-weight: bold;">or</span> <span style="color: #006699; font-weight: bold;">die</span>(mysqli_error());
<span style="color: #003333;">$sqlnya</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"SELECT * FROM parkir"</span>;
<span style="color: #003333;">$querynya</span> <span style="color: #555555;">=</span> mysqli_query(<span style="color: #003333;">$koneksinya</span>, <span style="color: #003333;">$sqlnya</span>);
<span style="color: #009999;">?></span>
<div class="containerr">
<span class="contact1-form-titlee" class="spannya">
Data Parkir
</span>
<table class="fixed_header">
<thead>
<tr>
<th>Kode Barcode</th>
<th>Jenis</th>
<th>Merek</th>
<th>Warna</th>
<th>Plat</th>
<th>Jam Masuk</th>
<th>Jam Keluar</th>
</tr>
</thead>
<tbody>
<span style="color: #009999;"><?php</span>
<span style="color: #006699; font-weight: bold;">while</span>(<span style="color: #003333;">$data</span> <span style="color: #555555;">=</span> mysqli_fetch_array(<span style="color: #003333;">$querynya</span>)){
<span style="color: #009999;">?></span>
<tr>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'KodeBarcode'</span>]; <span style="color: #009999;">?></span>
</td>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'Jenis'</span>]; <span style="color: #009999;">?></span>
</td>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'Merek'</span>]; <span style="color: #009999;">?></span>
</td>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'Warna'</span>]; <span style="color: #009999;">?></span>
</td>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'Plat'</span>]; <span style="color: #009999;">?></span>
</td>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'JamMasuk'</span>]; <span style="color: #009999;">?></span>
</td>
<td>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$data</span>[<span style="color: #cc3300;">'JamKeluar'</span>]; <span style="color: #009999;">?></span>
</td>
</tr>
<span style="color: #009999;"><?php</span>
}
<span style="color: #009999;">?></span>
</tbody>
</table>
</div>
</div>
<!--===============================================================================================-->
<script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script>
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/tilt/tilt.jquery.min.js"></script>
<script>
$('.js-tilt').tilt({
scale: 1.1
})
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-23581568-13"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-23581568-13');
</script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html>
</pre></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Selanjutnya, buka file <b>aksi.php</b> lalu masukkan kode berikut<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #009999;"><?php</span>
<span style="color: #0099ff; font-style: italic;">//Ini untuk koneksi saja</span>
<span style="color: #003333;">$user_name</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"youruser"</span>;
<span style="color: #003333;">$password</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"yourpwd"</span>;
<span style="color: #003333;">$database</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"barcode_park"</span>; <span style="color: #0099ff; font-style: italic;">//Tulis sesuai dengan nama database yang digunakan</span>
<span style="color: #003333;">$host_name</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"localhost"</span>;
<span style="color: #003333;">$connect_db</span><span style="color: #555555;">=</span><span style="color: #336666;">mysql_connect</span>(<span style="color: #003333;">$host_name</span>, <span style="color: #003333;">$user_name</span>, <span style="color: #003333;">$password</span>);
<span style="color: #003333;">$find_db</span><span style="color: #555555;">=</span><span style="color: #336666;">mysql_select_db</span>(<span style="color: #003333;">$database</span>);
<span style="color: #0099ff; font-style: italic;">//Akhir koneksi</span>
<span style="color: #0099ff; font-style: italic;">//Pertama ambil data kiriman dari form</span>
<span style="color: #003333;">$kode</span> <span style="color: #555555;">=</span> <span style="color: #555555;">@</span><span style="color: #003333;">$_POST</span>[<span style="color: #cc3300;">'KodeBarcode'</span>];
<span style="color: #003333;">$jenis</span> <span style="color: #555555;">=</span> <span style="color: #555555;">@</span><span style="color: #003333;">$_POST</span>[<span style="color: #cc3300;">'jenis'</span>];
<span style="color: #003333;">$plat</span> <span style="color: #555555;">=</span> <span style="color: #555555;">@</span><span style="color: #003333;">$_POST</span>[<span style="color: #cc3300;">'plat'</span>];
<span style="color: #003333;">$warna</span> <span style="color: #555555;">=</span> <span style="color: #555555;">@</span><span style="color: #003333;">$_POST</span>[<span style="color: #cc3300;">'warna'</span>];
<span style="color: #003333;">$merek</span> <span style="color: #555555;">=</span> <span style="color: #555555;">@</span><span style="color: #003333;">$_POST</span>[<span style="color: #cc3300;">'merek'</span>];
<span style="color: #003333;">$sql_simpan</span> <span style="color: #555555;">=</span> <span style="color: #336666;">mysql_query</span> (<span style="color: #cc3300;">"INSERT into parkir (KodeBarcode, Jenis, Plat, Warna, Merek, JamMasuk) VALUES ('</span><span style="color: #aa0000;">$kode</span><span style="color: #cc3300;">', '</span><span style="color: #aa0000;">$jenis</span><span style="color: #cc3300;">', '</span><span style="color: #aa0000;">$plat</span><span style="color: #cc3300;">', '</span><span style="color: #aa0000;">$warna</span><span style="color: #cc3300;">', '</span><span style="color: #aa0000;">$merek</span><span style="color: #cc3300;">', now())"</span>);
<span style="color: #006699; font-weight: bold;">include</span> <span style="color: #cc3300;">"phpqrcode/qrlib.php"</span>; <span style="color: #0099ff; font-style: italic;">//<-- LOKASI FILE UTAMA PLUGINNYA</span>
<span style="color: #003333;">$tempdir</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"temp/"</span>; <span style="color: #0099ff; font-style: italic;">//<-- Nama Folder file QR Code kita nantinya akan disimpan</span>
<span style="color: #006699; font-weight: bold;">if</span> (<span style="color: #555555;">!</span><span style="color: #336666;">file_exists</span>(<span style="color: #003333;">$tempdir</span>))<span style="color: #0099ff; font-style: italic;">#kalau folder belum ada, maka buat.</span>
<span style="color: #336666;">mkdir</span>(<span style="color: #003333;">$tempdir</span>);
<span style="color: #0099ff; font-style: italic;">//lanjutan yang tadi</span>
<span style="color: #0099ff; font-style: italic;">#parameter inputan</span>
<span style="color: #003333;">$isi_teks</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"</span><span style="color: #aa0000;">$kode</span><span style="color: #cc3300;">"</span>;
<span style="color: #003333;">$namafile</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"</span><span style="color: #aa0000;">$kode</span><span style="color: #cc3300;">.png"</span>;
<span style="color: #003333;">$quality</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">'H'</span>; <span style="color: #0099ff; font-style: italic;">//ada 4 pilihan, L (Low), M(Medium), Q(Good), H(High)</span>
<span style="color: #003333;">$ukuran</span> <span style="color: #555555;">=</span> <span style="color: #ff6600;">10</span>; <span style="color: #0099ff; font-style: italic;">//batasan 1 paling kecil, 10 paling besar</span>
<span style="color: #003333;">$padding</span> <span style="color: #555555;">=</span> <span style="color: #ff6600;">2</span>;
QRCode<span style="color: #555555;">::</span><span style="color: #330099;">png</span>(<span style="color: #003333;">$isi_teks</span>,<span style="color: #003333;">$tempdir</span><span style="color: #555555;">.</span><span style="color: #003333;">$namafile</span>,<span style="color: #003333;">$quality</span>,<span style="color: #003333;">$ukuran</span>,<span style="color: #003333;">$padding</span>);
<span style="color: #009999;">?></span>
<html lang="en">
<head>
<title>Contact V1</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/icons/favicon.ico" />
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
<style>
.container-contact1 {
width: auto;
border: 5px dotted #7a7777;
background: #fff;
border-radius: 15px;
overflow: hidden;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: grid;
flex-wrap: wrap;
justify-content: space-between;
align-content: center;
padding: 20px;
}
.titlenya{
color:#333333;
font-size: 24px;
}
</style>
</head>
<body>
<div class="contact1">
<div class="container-contact1">
<span class="contact1-form-title titlenya" style="padding-bottom: 20px;font-size:35px">
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span> <span style="color: #003333;">$kode</span> <span style="color: #009999;">?></span>
</span>
<span style="color: #009999;"><?php</span> <span style="color: #006699; font-weight: bold;">echo</span><span style="color: #cc3300;">"<img src='temp/</span><span style="color: #aa0000;">$kode</span><span style="color: #cc3300;">.png' style='width:450px'>"</span>; <span style="color: #009999;">?></span>
<a href="index.php" class="contact1-form-btn" style="text-decoration:none;border-radius: 15px;">Kembali</a>
</div>
</div>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/tilt/tilt.jquery.min.js"></script>
<script>
$('.js-tilt').tilt({
scale: 1.1
})
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-23581568-13"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-23581568-13');
</script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html>
</pre></div><br />
Setelah selesai, coba jalankan <b>index.php</b> melalui browser. tampilannya kurang lebih seperti pada gambar dibawah.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-tDjNt6xeTBI/XgyxAso1WCI/AAAAAAAABeE/1k6H94E-WBwB5_TgwNBOohvDftL0n32QQCLcBGAsYHQ/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="907" data-original-width="1600" src="https://1.bp.blogspot.com/-tDjNt6xeTBI/XgyxAso1WCI/AAAAAAAABeE/1k6H94E-WBwB5_TgwNBOohvDftL0n32QQCLcBGAsYHQ/s1600/3.png" /></a></div><br />
Untuk nomor parkir sifatnya otomatis, jadi setiap transaksi selesai, maka PARK-0001 akan berubah menjadi PARK-0002. seterusnya seperti itu. Setelah mengisi semuanya lalu menekan tombol Simpan maka akan pindah ke halaman selanjutnya untuk menampilkan QR Code.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-5wqoDGWUSfE/Xg3sxt143II/AAAAAAAABec/Kf7E56o8Ib4e10f90kBmnN0dRUQTp_ooQCLcBGAsYHQ/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="953" data-original-width="1600" src="https://1.bp.blogspot.com/-5wqoDGWUSfE/Xg3sxt143II/AAAAAAAABec/Kf7E56o8Ib4e10f90kBmnN0dRUQTp_ooQCLcBGAsYHQ/s1600/4.png" /></a></div><br />
QR Code ini kita asumsikan sebagai struk yang diberikan kepada pengunjung. Selanjutnya kita buat aplikasi berbasis android yang akan digunakan oleh petugas gerbang keluar untuk melakukan pemindaian pada QR Code yang didapatkan sebelumnya.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Setelah membuat project baru, buka bagian <b>dependencies</b> lalu tambahkan library yang dibutuhkan.<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;">implementation <span style="color: #cc3300;">'com.journeyapps:zxing-android-embedded:3.4.0'</span>
implementation <span style="color: #cc3300;">'com.google.zxing:core:3.2.1'</span>
implementation <span style="color: #cc00ff;">files</span>(<span style="color: #cc3300;">'libs/mysql-connector'</span>)
</pre></div><br />
Pastikan kamu sudah menyimpan library <b><a href="https://drive.google.com/open?id=1CiEjIbwL1a4cjMYAyHRjqlqCihoW3-el" target="_blank">mysql-connector</a></b> kedalam folder <b>libs</b> (nama_project/app/libs) dan pastikan nama filenya sama.<br />
<br />
selanjutnya buka <b>activity_main.xml</b> untuk mendesain layout aplikasi android, lalu masukkan kode berikut<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #330099; font-weight: bold;"><ScrollView</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/scr"</span>
<span style="color: #330099;">android:focusable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:focusableInTouchMode=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:fillViewport=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><RelativeLayout</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/frag1"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"#fff"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><LinearLayout</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/atass"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><LinearLayout</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/collapsing_tool_bar_layout"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><LinearLayout</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/atasnya"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"#123"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span>
<span style="color: #330099;">android:padding=</span><span style="color: #cc3300;">"20dp"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/kodeBarcode"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/jenisKendara"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/merek"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/warna"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/plat"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/masuk"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/keluar"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><TextView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/lama"</span>
<span style="color: #330099;">android:drawableLeft=</span><span style="color: #cc3300;">"@drawable/ic_text_subject_grey600_24dp"</span>
<span style="color: #330099;">android:drawablePadding=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:layout_marginBottom=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:autoLink=</span><span style="color: #cc3300;">"email|web|map"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">""</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textIsSelectable=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"#f5f5f5"</span>
<span style="color: #330099;">android:textSize=</span><span style="color: #cc3300;">"17dp"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"></LinearLayout></span>
<span style="color: #330099; font-weight: bold;"></LinearLayout></span>
<span style="color: #330099; font-weight: bold;"><LinearLayout</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"horizontal"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"@color/colorPrimary"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"50dp"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><Button</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/simpan"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:textColor=</span><span style="color: #cc3300;">"@color/colorAccent"</span>
<span style="color: #330099;">android:text=</span><span style="color: #cc3300;">"Clean All"</span><span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"></LinearLayout></span>
<span style="color: #330099; font-weight: bold;"><RelativeLayout</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"350dp"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/anue"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><ImageView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/qrcode"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_centerInParent=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:scaleType=</span><span style="color: #cc3300;">"fitXY"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"></RelativeLayout></span>
<span style="color: #330099; font-weight: bold;"></LinearLayout></span>
<span style="color: #330099; font-weight: bold;"></RelativeLayout></span>
<span style="color: #330099; font-weight: bold;"></ScrollView></span>
</pre></div><br />
Tampilan dari kode diatas kurang lebih seperti ini gambar dibawah<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-fQzAN1M4CVA/Xg3wot1qG1I/AAAAAAAABe0/D4ZkotGegZ0AyrZzEy7RGassD5xxba_-ACLcBGAsYHQ/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="617" data-original-width="381" src="https://1.bp.blogspot.com/-fQzAN1M4CVA/Xg3wot1qG1I/AAAAAAAABe0/D4ZkotGegZ0AyrZzEy7RGassD5xxba_-ACLcBGAsYHQ/s1600/5.png" /></a></div><br />
Jika sudah selesai kita masuk pada <b>MainActivity.java</b> lalu masukkan kode berikut<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.content.Intent</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.graphics.Bitmap</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.graphics.Color</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.media.AudioManager</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.media.ToneGenerator</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.os.AsyncTask</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.os.Build</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.support.annotation.RequiresApi</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.support.design.widget.Snackbar</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.support.v7.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.view.Menu</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.view.MenuItem</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.Button</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.FrameLayout</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.ImageView</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.RelativeLayout</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.TextView</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">android.widget.Toast</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.google.zxing.BarcodeFormat</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.google.zxing.MultiFormatWriter</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.google.zxing.WriterException</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.google.zxing.common.BitMatrix</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.google.zxing.integration.android.IntentIntegrator</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.google.zxing.integration.android.IntentResult</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.journeyapps.barcodescanner.BarcodeEncoder</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.sql.Connection</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.sql.DriverManager</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.sql.ResultSet</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.sql.ResultSetMetaData</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.sql.Statement</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.text.SimpleDateFormat</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.util.Calendar</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">java.util.Date</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">class</span> <span style="color: #00aa88; font-weight: bold;">MainActivity</span> <span style="color: #006699; font-weight: bold;">extends</span> AppCompatActivity<span style="color: #555555;">{</span>
String jenisnya<span style="color: #555555;">,</span>masuknya<span style="color: #555555;">,</span>keluarnya<span style="color: #555555;">,</span>platnya<span style="color: #555555;">,</span>mereknya<span style="color: #555555;">,</span>warnanya<span style="color: #555555;">,</span> lamaparkir<span style="color: #555555;">;</span>
<span style="color: #007788; font-weight: bold;">int</span> totalbayar<span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">private</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">final</span> String url <span style="color: #555555;">=</span> <span style="color: #cc3300;">"jdbc:mysql://192.168.43.93:3306/Barcode_Park"</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">private</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">final</span> String user <span style="color: #555555;">=</span> <span style="color: #cc3300;">"youruser"</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">private</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">final</span> String pass <span style="color: #555555;">=</span> <span style="color: #cc3300;">"yourpwd"</span><span style="color: #555555;">;</span>
TextView kodeBarcode<span style="color: #555555;">,</span>jenis_kendara<span style="color: #555555;">,</span>masuk<span style="color: #555555;">,</span>keluar<span style="color: #555555;">,</span>plat<span style="color: #555555;">,</span>merek<span style="color: #555555;">,</span>warna<span style="color: #555555;">,</span>lama<span style="color: #555555;">;</span>
ImageView qrcode1<span style="color: #555555;">;</span>
Button simpan<span style="color: #555555;">;</span>
RelativeLayout rl<span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">protected</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">qrcode</span><span style="color: #555555;">);</span>
getSupportActionBar<span style="color: #555555;">().</span><span style="color: #330099;">setTitle</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"Scan QR Code"</span><span style="color: #555555;">);</span>
rl <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">anue</span><span style="color: #555555;">);</span>
kodeBarcode <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">kodeBarcode</span><span style="color: #555555;">);</span>
masuk <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">masuk</span><span style="color: #555555;">);</span>
jenis_kendara <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">jenisKendara</span><span style="color: #555555;">);</span>
keluar <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">keluar</span><span style="color: #555555;">);</span>
plat <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">plat</span><span style="color: #555555;">);</span>
merek <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">merek</span><span style="color: #555555;">);</span>
warna <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">warna</span><span style="color: #555555;">);</span>
lama <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">lama</span><span style="color: #555555;">);</span>
qrcode1 <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">qrcode</span><span style="color: #555555;">);</span>
simpan <span style="color: #555555;">=</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">simpan</span><span style="color: #555555;">);</span>
simpan<span style="color: #555555;">.</span><span style="color: #330099;">setOnClickListener</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">new</span> View<span style="color: #555555;">.</span><span style="color: #330099;">OnClickListener</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onClick</span><span style="color: #555555;">(</span>View v<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
bersih<span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">});</span>
<span style="color: #555555;">}</span>
<span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">bersih</span><span style="color: #555555;">(){</span>
kodeBarcode<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
jenis_kendara<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
masuk<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
keluar<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
plat<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
warna<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
merek<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
lama<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
qrcode1<span style="color: #555555;">.</span><span style="color: #330099;">setImageBitmap</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">null</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">private</span> <span style="color: #006699; font-weight: bold;">class</span> <span style="color: #00aa88; font-weight: bold;">ConnectMySql</span> <span style="color: #006699; font-weight: bold;">extends</span> AsyncTask<span style="color: #555555;"><</span>String<span style="color: #555555;">,</span> Void<span style="color: #555555;">,</span> String<span style="color: #555555;">></span> <span style="color: #555555;">{</span>
String res <span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">protected</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onPreExecute</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onPreExecute</span><span style="color: #555555;">();</span>
<span style="color: #0099ff; font-style: italic;">// Toast.makeText(ScanBarcode.this, "Please wait...", Toast.LENGTH_SHORT)</span>
<span style="color: #0099ff; font-style: italic;">// .show();</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@RequiresApi</span><span style="color: #555555;">(</span>api <span style="color: #555555;">=</span> Build<span style="color: #555555;">.</span><span style="color: #330099;">VERSION_CODES</span><span style="color: #555555;">.</span><span style="color: #330099;">M</span><span style="color: #555555;">)</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">protected</span> String <span style="color: #cc00ff;">doInBackground</span><span style="color: #555555;">(</span>String<span style="color: #555555;">...</span> params<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">try</span> <span style="color: #555555;">{</span>
Calendar c1 <span style="color: #555555;">=</span> Calendar<span style="color: #555555;">.</span><span style="color: #330099;">getInstance</span><span style="color: #555555;">();</span>
SimpleDateFormat sdf1 <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #555555;">(</span><span style="color: #cc3300;">"yyyy-MM-dd HH:mm:ss"</span><span style="color: #555555;">);</span>
lamaparkir <span style="color: #555555;">=</span> sdf1<span style="color: #555555;">.</span><span style="color: #330099;">format</span><span style="color: #555555;">(</span>c1<span style="color: #555555;">.</span><span style="color: #330099;">getTime</span><span style="color: #555555;">());</span>
Class<span style="color: #555555;">.</span><span style="color: #330099;">forName</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"com.mysql.jdbc.Driver"</span><span style="color: #555555;">);</span>
Connection con <span style="color: #555555;">=</span> DriverManager<span style="color: #555555;">.</span><span style="color: #330099;">getConnection</span><span style="color: #555555;">(</span>url<span style="color: #555555;">,</span> user<span style="color: #555555;">,</span> pass<span style="color: #555555;">);</span>
<span style="color: #0099ff; font-style: italic;">//System.out.println("Databaseection success");</span>
Statement st <span style="color: #555555;">=</span> con<span style="color: #555555;">.</span><span style="color: #330099;">createStatement</span><span style="color: #555555;">();</span>
st<span style="color: #555555;">.</span><span style="color: #330099;">executeUpdate</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"update parkir set JamKeluar = '"</span><span style="color: #555555;">+</span> lamaparkir <span style="color: #555555;">+</span> <span style="color: #cc3300;">"' where KodeBarcode = '"</span> <span style="color: #555555;">+</span>kodeBarcode<span style="color: #555555;">.</span><span style="color: #330099;">getText</span><span style="color: #555555;">().</span><span style="color: #330099;">toString</span><span style="color: #555555;">().</span><span style="color: #330099;">trim</span><span style="color: #555555;">()+</span> <span style="color: #cc3300;">"'"</span><span style="color: #555555;">);</span>
ResultSet rs <span style="color: #555555;">=</span> st<span style="color: #555555;">.</span><span style="color: #330099;">executeQuery</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"select * from parkir where KodeBarcode ="</span><span style="color: #555555;">+</span> <span style="color: #cc3300;">"'"</span><span style="color: #555555;">+</span>kodeBarcode<span style="color: #555555;">.</span><span style="color: #330099;">getText</span><span style="color: #555555;">().</span><span style="color: #330099;">toString</span><span style="color: #555555;">().</span><span style="color: #330099;">trim</span><span style="color: #555555;">()+</span><span style="color: #cc3300;">"'"</span><span style="color: #555555;">);</span>
ResultSetMetaData rsmd <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getMetaData</span><span style="color: #555555;">();</span>
<span style="color: #006699; font-weight: bold;">if</span> <span style="color: #555555;">(</span>rs<span style="color: #555555;">.</span><span style="color: #330099;">next</span><span style="color: #555555;">())</span> <span style="color: #555555;">{</span>
jenisnya <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getString</span><span style="color: #555555;">(</span><span style="color: #ff6600;">3</span><span style="color: #555555;">).</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
mereknya <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getString</span><span style="color: #555555;">(</span><span style="color: #ff6600;">4</span><span style="color: #555555;">).</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
warnanya <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getString</span><span style="color: #555555;">(</span><span style="color: #ff6600;">5</span><span style="color: #555555;">).</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
platnya <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getString</span><span style="color: #555555;">(</span><span style="color: #ff6600;">6</span><span style="color: #555555;">).</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
masuknya <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getString</span><span style="color: #555555;">(</span><span style="color: #ff6600;">7</span><span style="color: #555555;">).</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
keluarnya <span style="color: #555555;">=</span> rs<span style="color: #555555;">.</span><span style="color: #330099;">getString</span><span style="color: #555555;">(</span><span style="color: #ff6600;">8</span><span style="color: #555555;">).</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
Snackbar snackbar <span style="color: #555555;">=</span> Snackbar
<span style="color: #555555;">.</span><span style="color: #330099;">make</span><span style="color: #555555;">(</span>getCurrentFocus<span style="color: #555555;">(),</span> <span style="color: #cc3300;">"QR Code Terdeteksi"</span><span style="color: #555555;">,</span> Snackbar<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">);</span>
View sbView <span style="color: #555555;">=</span> snackbar<span style="color: #555555;">.</span><span style="color: #330099;">getView</span><span style="color: #555555;">();</span>
sbView<span style="color: #555555;">.</span><span style="color: #330099;">setBackgroundColor</span><span style="color: #555555;">(</span>getColor<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">color</span><span style="color: #555555;">.</span><span style="color: #330099;">colorPrimaryDark</span><span style="color: #555555;">));</span>
TextView textView <span style="color: #555555;">=</span> sbView<span style="color: #555555;">.</span><span style="color: #330099;">findViewById</span><span style="color: #555555;">(</span>android<span style="color: #555555;">.</span><span style="color: #330099;">support</span><span style="color: #555555;">.</span><span style="color: #330099;">design</span><span style="color: #555555;">.</span><span style="color: #330099;">R</span><span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">snackbar_text</span><span style="color: #555555;">);</span>
textView<span style="color: #555555;">.</span><span style="color: #330099;">setTextColor</span><span style="color: #555555;">(</span>Color<span style="color: #555555;">.</span><span style="color: #330099;">WHITE</span><span style="color: #555555;">);</span>
snackbar<span style="color: #555555;">.</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
ToneGenerator toneGen1 <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> ToneGenerator<span style="color: #555555;">(</span>AudioManager<span style="color: #555555;">.</span><span style="color: #330099;">STREAM_ALARM</span><span style="color: #555555;">,</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">);</span>
toneGen1<span style="color: #555555;">.</span><span style="color: #330099;">startTone</span><span style="color: #555555;">(</span>ToneGenerator<span style="color: #555555;">.</span><span style="color: #330099;">TONE_PROP_BEEP</span><span style="color: #555555;">,</span><span style="color: #ff6600;">150</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">else</span><span style="color: #555555;">{</span>
jenisnya<span style="color: #555555;">=</span> <span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
mereknya<span style="color: #555555;">=</span><span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
warnanya<span style="color: #555555;">=</span><span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
platnya<span style="color: #555555;">=</span><span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
masuknya<span style="color: #555555;">=</span><span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
keluarnya<span style="color: #555555;">=</span><span style="color: #cc3300;">""</span><span style="color: #555555;">;</span>
Snackbar snackbar <span style="color: #555555;">=</span> Snackbar
<span style="color: #555555;">.</span><span style="color: #330099;">make</span><span style="color: #555555;">(</span>getCurrentFocus<span style="color: #555555;">(),</span> <span style="color: #cc3300;">"QR Code Tidak Terdeteksi"</span><span style="color: #555555;">,</span> Snackbar<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">);</span>
View sbView <span style="color: #555555;">=</span> snackbar<span style="color: #555555;">.</span><span style="color: #330099;">getView</span><span style="color: #555555;">();</span>
sbView<span style="color: #555555;">.</span><span style="color: #330099;">setBackgroundColor</span><span style="color: #555555;">(</span>getColor<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">color</span><span style="color: #555555;">.</span><span style="color: #330099;">merah</span><span style="color: #555555;">));</span>
TextView textView <span style="color: #555555;">=</span> sbView<span style="color: #555555;">.</span><span style="color: #330099;">findViewById</span><span style="color: #555555;">(</span>android<span style="color: #555555;">.</span><span style="color: #330099;">support</span><span style="color: #555555;">.</span><span style="color: #330099;">design</span><span style="color: #555555;">.</span><span style="color: #330099;">R</span><span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">snackbar_text</span><span style="color: #555555;">);</span>
textView<span style="color: #555555;">.</span><span style="color: #330099;">setTextColor</span><span style="color: #555555;">(</span>Color<span style="color: #555555;">.</span><span style="color: #330099;">WHITE</span><span style="color: #555555;">);</span>
snackbar<span style="color: #555555;">.</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
ToneGenerator toneGen1 <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> ToneGenerator<span style="color: #555555;">(</span>AudioManager<span style="color: #555555;">.</span><span style="color: #330099;">STREAM_ALARM</span><span style="color: #555555;">,</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">);</span>
toneGen1<span style="color: #555555;">.</span><span style="color: #330099;">startTone</span><span style="color: #555555;">(</span>ToneGenerator<span style="color: #555555;">.</span><span style="color: #330099;">TONE_SUP_ERROR</span><span style="color: #555555;">,</span><span style="color: #ff6600;">150</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span> <span style="color: #006699; font-weight: bold;">catch</span> <span style="color: #555555;">(</span>Exception e<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
e<span style="color: #555555;">.</span><span style="color: #330099;">printStackTrace</span><span style="color: #555555;">();</span>
res <span style="color: #555555;">=</span> e<span style="color: #555555;">.</span><span style="color: #330099;">toString</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">return</span> res<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">protected</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onPostExecute</span><span style="color: #555555;">(</span>String result<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">try</span> <span style="color: #555555;">{</span>
<span style="color: #0099ff; font-style: italic;">// NumberFormat formatter = new DecimalFormat("#,##0");</span>
Calendar c1 <span style="color: #555555;">=</span> Calendar<span style="color: #555555;">.</span><span style="color: #330099;">getInstance</span><span style="color: #555555;">();</span>
SimpleDateFormat sdf1 <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #555555;">(</span><span style="color: #cc3300;">"yyyy-MM-dd HH:mm:ss"</span><span style="color: #555555;">);</span>
lamaparkir <span style="color: #555555;">=</span> sdf1<span style="color: #555555;">.</span><span style="color: #330099;">format</span><span style="color: #555555;">(</span>c1<span style="color: #555555;">.</span><span style="color: #330099;">getTime</span><span style="color: #555555;">());</span>
SimpleDateFormat format <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #555555;">(</span><span style="color: #cc3300;">"MM/dd/yyyy HH:mm:ss"</span><span style="color: #555555;">);</span>
jenis_kendara<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>jenisnya<span style="color: #555555;">);</span>
merek<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>mereknya<span style="color: #555555;">);</span>
warna<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>warnanya<span style="color: #555555;">);</span>
plat<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>platnya<span style="color: #555555;">);</span>
masuk<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>masuknya<span style="color: #555555;">);</span>
keluar<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>keluarnya<span style="color: #555555;">);</span>
Date d1 <span style="color: #555555;">=</span> format<span style="color: #555555;">.</span><span style="color: #330099;">parse</span><span style="color: #555555;">(</span>masuknya<span style="color: #555555;">.</span><span style="color: #330099;">replace</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"-"</span><span style="color: #555555;">,</span> <span style="color: #cc3300;">"/"</span><span style="color: #555555;">));</span>
Date d2 <span style="color: #555555;">=</span> format<span style="color: #555555;">.</span><span style="color: #330099;">parse</span><span style="color: #555555;">(</span>lamaparkir<span style="color: #555555;">.</span><span style="color: #330099;">replace</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"-"</span><span style="color: #555555;">,</span> <span style="color: #cc3300;">"/"</span><span style="color: #555555;">));</span>
<span style="color: #007788; font-weight: bold;">long</span> diff <span style="color: #555555;">=</span> d2<span style="color: #555555;">.</span><span style="color: #330099;">getTime</span><span style="color: #555555;">()</span> <span style="color: #555555;">-</span> d1<span style="color: #555555;">.</span><span style="color: #330099;">getTime</span><span style="color: #555555;">();</span>
<span style="color: #007788; font-weight: bold;">long</span> diffSeconds <span style="color: #555555;">=</span> diff <span style="color: #555555;">/</span> <span style="color: #ff6600;">1000</span> <span style="color: #555555;">%</span> <span style="color: #ff6600;">60</span><span style="color: #555555;">;</span>
<span style="color: #007788; font-weight: bold;">long</span> diffMinutes <span style="color: #555555;">=</span> diff <span style="color: #555555;">/</span> <span style="color: #555555;">(</span><span style="color: #ff6600;">60</span> <span style="color: #555555;">*</span> <span style="color: #ff6600;">1000</span><span style="color: #555555;">)</span> <span style="color: #555555;">%</span> <span style="color: #ff6600;">60</span><span style="color: #555555;">;</span>
<span style="color: #007788; font-weight: bold;">long</span> diffHours <span style="color: #555555;">=</span> diff <span style="color: #555555;">/</span> <span style="color: #555555;">(</span><span style="color: #ff6600;">60</span> <span style="color: #555555;">*</span> <span style="color: #ff6600;">60</span> <span style="color: #555555;">*</span> <span style="color: #ff6600;">1000</span><span style="color: #555555;">)</span> <span style="color: #555555;">%</span> <span style="color: #ff6600;">24</span><span style="color: #555555;">;</span>
<span style="color: #007788; font-weight: bold;">long</span> diffDays <span style="color: #555555;">=</span> diff <span style="color: #555555;">/</span> <span style="color: #555555;">(</span><span style="color: #ff6600;">24</span> <span style="color: #555555;">*</span> <span style="color: #ff6600;">60</span> <span style="color: #555555;">*</span> <span style="color: #ff6600;">60</span> <span style="color: #555555;">*</span> <span style="color: #ff6600;">1000</span><span style="color: #555555;">);</span>
lama<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>String<span style="color: #555555;">.</span><span style="color: #330099;">valueOf</span><span style="color: #555555;">(</span>diffHours <span style="color: #555555;">+</span> <span style="color: #cc3300;">" Jam "</span> <span style="color: #555555;">+</span>diffMinutes<span style="color: #555555;">+</span><span style="color: #cc3300;">" Menit "</span><span style="color: #555555;">+</span>diffSeconds<span style="color: #555555;">+</span><span style="color: #cc3300;">" Detik"</span><span style="color: #555555;">));</span>
<span style="color: #555555;">}</span> <span style="color: #006699; font-weight: bold;">catch</span> <span style="color: #555555;">(</span>Exception e<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
e<span style="color: #555555;">.</span><span style="color: #330099;">printStackTrace</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">protected</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">onActivityResult</span><span style="color: #555555;">(</span><span style="color: #007788; font-weight: bold;">int</span> requestCode<span style="color: #555555;">,</span> <span style="color: #007788; font-weight: bold;">int</span> resultCode<span style="color: #555555;">,</span> Intent data<span style="color: #555555;">){</span>
IntentResult result <span style="color: #555555;">=</span> IntentIntegrator<span style="color: #555555;">.</span><span style="color: #330099;">parseActivityResult</span><span style="color: #555555;">(</span>requestCode<span style="color: #555555;">,</span>resultCode<span style="color: #555555;">,</span>data<span style="color: #555555;">);</span>
<span style="color: #006699; font-weight: bold;">if</span> <span style="color: #555555;">(</span>result <span style="color: #555555;">!=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #555555;">){</span>
<span style="color: #006699; font-weight: bold;">if</span> <span style="color: #555555;">(</span>result<span style="color: #555555;">.</span><span style="color: #330099;">getContents</span><span style="color: #555555;">()</span> <span style="color: #555555;">==</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #555555;">){</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">this</span><span style="color: #555555;">,</span><span style="color: #cc3300;">"Barcode Tidak Ada"</span><span style="color: #555555;">,</span> Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_SHORT</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
qrcode1<span style="color: #555555;">.</span><span style="color: #330099;">setImageBitmap</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">null</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">else</span><span style="color: #555555;">{</span>
kodeBarcode<span style="color: #555555;">.</span><span style="color: #330099;">setText</span><span style="color: #555555;">(</span>result<span style="color: #555555;">.</span><span style="color: #330099;">getContents</span><span style="color: #555555;">());</span>
MultiFormatWriter multiFormatWriter <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> MultiFormatWriter<span style="color: #555555;">();</span>
<span style="color: #006699; font-weight: bold;">try</span> <span style="color: #555555;">{</span>
rl<span style="color: #555555;">.</span><span style="color: #330099;">requestLayout</span><span style="color: #555555;">();</span>
qrcode1<span style="color: #555555;">.</span><span style="color: #330099;">requestLayout</span><span style="color: #555555;">();</span>
rl<span style="color: #555555;">.</span><span style="color: #330099;">getLayoutParams</span><span style="color: #555555;">().</span><span style="color: #330099;">width</span> <span style="color: #555555;">=</span> FrameLayout<span style="color: #555555;">.</span><span style="color: #330099;">LayoutParams</span><span style="color: #555555;">.</span><span style="color: #330099;">MATCH_PARENT</span><span style="color: #555555;">;</span>
rl<span style="color: #555555;">.</span><span style="color: #330099;">getLayoutParams</span><span style="color: #555555;">().</span><span style="color: #330099;">height</span> <span style="color: #555555;">=</span> rl<span style="color: #555555;">.</span><span style="color: #330099;">getWidth</span><span style="color: #555555;">();</span>
qrcode1<span style="color: #555555;">.</span><span style="color: #330099;">getLayoutParams</span><span style="color: #555555;">().</span><span style="color: #330099;">width</span> <span style="color: #555555;">=</span> rl<span style="color: #555555;">.</span><span style="color: #330099;">getWidth</span><span style="color: #555555;">();</span>
qrcode1<span style="color: #555555;">.</span><span style="color: #330099;">getLayoutParams</span><span style="color: #555555;">().</span><span style="color: #330099;">height</span> <span style="color: #555555;">=</span> rl<span style="color: #555555;">.</span><span style="color: #330099;">getWidth</span><span style="color: #555555;">();</span>
BitMatrix bitMatrix <span style="color: #555555;">=</span> multiFormatWriter<span style="color: #555555;">.</span><span style="color: #330099;">encode</span><span style="color: #555555;">(</span>kodeBarcode<span style="color: #555555;">.</span><span style="color: #330099;">getText</span><span style="color: #555555;">().</span><span style="color: #330099;">toString</span><span style="color: #555555;">(),</span> BarcodeFormat<span style="color: #555555;">.</span><span style="color: #330099;">valueOf</span><span style="color: #555555;">(</span>result<span style="color: #555555;">.</span><span style="color: #330099;">getFormatName</span><span style="color: #555555;">()),</span> <span style="color: #ff6600;">1000</span><span style="color: #555555;">,</span><span style="color: #ff6600;">1000</span><span style="color: #555555;">);</span>
BarcodeEncoder barcodeEncoder <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> BarcodeEncoder<span style="color: #555555;">();</span>
Bitmap bitmap <span style="color: #555555;">=</span> barcodeEncoder<span style="color: #555555;">.</span><span style="color: #330099;">createBitmap</span><span style="color: #555555;">(</span>bitMatrix<span style="color: #555555;">);</span>
qrcode1<span style="color: #555555;">.</span><span style="color: #330099;">setImageBitmap</span><span style="color: #555555;">(</span>bitmap<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span> <span style="color: #006699; font-weight: bold;">catch</span> <span style="color: #555555;">(</span>WriterException e<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>ScanBarcode<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span> e<span style="color: #555555;">.</span><span style="color: #330099;">toString</span><span style="color: #555555;">(),</span> Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_SHORT</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">try</span><span style="color: #555555;">{</span>
ConnectMySql connectMySql <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> ConnectMySql<span style="color: #555555;">();</span>
connectMySql<span style="color: #555555;">.</span><span style="color: #330099;">execute</span><span style="color: #555555;">(</span><span style="color: #cc3300;">""</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span><span style="color: #006699; font-weight: bold;">catch</span> <span style="color: #555555;">(</span>Exception e<span style="color: #555555;">){</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>ScanBarcode<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span> e<span style="color: #555555;">.</span><span style="color: #330099;">toString</span><span style="color: #555555;">(),</span> Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_SHORT</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">else</span><span style="color: #555555;">{</span>
<span style="color: #006699; font-weight: bold;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onActivityResult</span><span style="color: #555555;">(</span>requestCode<span style="color: #555555;">,</span> resultCode<span style="color: #555555;">,</span> data<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #007788; font-weight: bold;">void</span> <span style="color: #cc00ff;">scanow</span><span style="color: #555555;">(){</span>
IntentIntegrator integrator <span style="color: #555555;">=</span> <span style="color: #006699; font-weight: bold;">new</span> IntentIntegrator<span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">this</span><span style="color: #555555;">);</span>
integrator<span style="color: #555555;">.</span><span style="color: #330099;">setCaptureActivity</span><span style="color: #555555;">(</span>Portrait<span style="color: #555555;">.</span><span style="color: #330099;">class</span><span style="color: #555555;">);</span>
integrator<span style="color: #555555;">.</span><span style="color: #330099;">setOrientationLocked</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">false</span><span style="color: #555555;">);</span>
integrator<span style="color: #555555;">.</span><span style="color: #330099;">setDesiredBarcodeFormats</span><span style="color: #555555;">(</span>IntentIntegrator<span style="color: #555555;">.</span><span style="color: #330099;">ALL_CODE_TYPES</span><span style="color: #555555;">);</span>
integrator<span style="color: #555555;">.</span><span style="color: #330099;">setBeepEnabled</span><span style="color: #555555;">(</span><span style="color: #006699; font-weight: bold;">false</span><span style="color: #555555;">);</span>
integrator<span style="color: #555555;">.</span><span style="color: #330099;">setPrompt</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"Scan QR Code"</span><span style="color: #555555;">);</span>
integrator<span style="color: #555555;">.</span><span style="color: #330099;">initiateScan</span><span style="color: #555555;">();</span>
bersih<span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #007788; font-weight: bold;">boolean</span> <span style="color: #cc00ff;">onCreateOptionsMenu</span><span style="color: #555555;">(</span>Menu menu<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
getMenuInflater<span style="color: #555555;">().</span><span style="color: #330099;">inflate</span><span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">menu</span><span style="color: #555555;">.</span><span style="color: #330099;">menu_scan</span><span style="color: #555555;">,</span> menu<span style="color: #555555;">);</span>
<span style="color: #006699; font-weight: bold;">return</span> <span style="color: #006699; font-weight: bold;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #007788; font-weight: bold;">boolean</span> <span style="color: #cc00ff;">onOptionsItemSelected</span><span style="color: #555555;">(</span>MenuItem item<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #007788; font-weight: bold;">int</span> id <span style="color: #555555;">=</span> item<span style="color: #555555;">.</span><span style="color: #330099;">getItemId</span><span style="color: #555555;">();</span>
<span style="color: #006699; font-weight: bold;">if</span> <span style="color: #555555;">(</span>id <span style="color: #555555;">==</span> R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">scan</span><span style="color: #555555;">){</span>
scanow<span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #006699; font-weight: bold;">return</span> <span style="color: #006699; font-weight: bold;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onOptionsItemSelected</span><span style="color: #555555;">(</span>item<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
</pre></div><br />
Jika sudah selesai, kamu perlu memperhatikan potongan kode berikut<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">private</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">final</span> String url <span style="color: #555555;">=</span> <span style="color: #cc3300;">"jdbc:mysql://192.168.43.93:3306/Barcode_Park"</span><span style="color: #555555;">;</span>
</pre></div><br />
Pastikan kamu sudah menghubungkan laptop atau PC kamu dengan hotspot smartphone yang digunakan untuk menjalankan aplikasi berbasis android, lalu masukkan lalu ganti <b>ip address</b> diatas.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Setelah itu, buka folder <b>menu</b> pada project android kalian lalu ubah file menu.xml didalamnya dengan kode berikut<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #330099; font-weight: bold;"><menu</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">xmlns:app=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res-auto"</span>
<span style="color: #330099;">xmlns:tools=</span><span style="color: #cc3300;">"http://schemas.android.com/tools"</span>
<span style="color: #330099;">tools:context=</span><span style="color: #cc3300;">".MainActivity"</span><span style="color: #330099; font-weight: bold;">></span>
<span style="color: #330099; font-weight: bold;"><item</span> <span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/scan"</span>
<span style="color: #330099;">android:title=</span><span style="color: #cc3300;">"Scan Now"</span>
<span style="color: #330099;">android:icon=</span><span style="color: #cc3300;">"@drawable/ic_barcode_scan_white_24dp"</span>
<span style="color: #330099;">android:orderInCategory=</span><span style="color: #cc3300;">"100"</span>
<span style="color: #330099;">app:showAsAction=</span><span style="color: #cc3300;">"always"</span> <span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"></menu></span>
</pre></div><br />
Sampai disini program masih belum dapat dijalankan karena masih ada 1 class lagi yang belum dibuat yaitu <b>Portrait.java</b> class ini berfungsi untuk mengatur pengambilan gambar secara portrait, sekarang buat class Portrait lalu masukkan kode berikut<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #006699; font-weight: bold;">import</span> <span style="color: #00ccff; font-weight: bold;">com.journeyapps.barcodescanner.CaptureActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">class</span> <span style="color: #00aa88; font-weight: bold;">Portrait</span> <span style="color: #006699; font-weight: bold;">extends</span> CaptureActivity <span style="color: #555555;">{</span>
<span style="color: #555555;">}</span>
</pre></div><br />
Jika sudah selesai, jangan lupa menambahkan <b>activity </b>class portrait kedalam <b>manifest.xml </b>kemudian tambahkan permisi untuk menggunakan kamera dan jaringan internet<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; border-width: 0.1em 0.1em 0.1em 0.1em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="color: #330099; font-weight: bold;"><uses-permission</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.permission.INTERNET"</span><span style="color: #330099; font-weight: bold;">/></span>
<span style="color: #330099; font-weight: bold;"><uses-permission</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.permission.CAMERA"</span><span style="color: #330099; font-weight: bold;">/></span>
</pre></div><br />
Selanjutnya, jalankan programnya<br />
Untuk lebih jelasnya kamu dapat mengunduh source code <a href="https://github.com/andiaspin/App-Parkir-Dengan-QRCode" target="_blank">disini</a>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndonesia-0.789275 113.92132700000002-31.6684965 72.61273300000002 30.0899465 155.22992100000002tag:blogger.com,1999:blog-3825706424405165268.post-88725446169789015182019-10-13T19:32:00.000+08:002019-10-13T19:32:17.839+08:00Create Loader Text HTML CSS<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/--URV5FwytZs/W7CM9rYnNDI/AAAAAAAABYE/VryL3EGTKf8qSwsiXPKczEFnUjYoxNFTwCLcBGAs/s1600/LOADER%2BTEXT.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="738" data-original-width="1330" src="https://3.bp.blogspot.com/--URV5FwytZs/W7CM9rYnNDI/AAAAAAAABYE/VryL3EGTKf8qSwsiXPKczEFnUjYoxNFTwCLcBGAs/s1600/LOADER%2BTEXT.jpg" /></a></div>
<br />
<hr />
<br />
Hello guys, this tutorial I will make a simple loader effect using text. So this program will display a word with less clear opacity and slowly become clearer until the written word appears clearly.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
First, create a project folder and add the <b>index.html and style.css</b> files in it. When finished open the <b>index.html</b> file and enter the following code<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Loader Text<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><h1</span> <span style="color: #330099;">data-text=</span><span style="color: #cc3300;">"Programming..."</span><span style="color: #330099;">></span>Programming...<span style="color: #330099;"></h1></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
Next, open <b>style.css</b> and enter the foloowing code<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>
{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span><span style="color: #006699;">sans-serif</span>;
}
<span style="color: #330099;">h1</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,</span> <span style="color: #ff6600;">-50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">120px</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">5px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#f5ebeb</span>f1;
}
<span style="color: #330099;">h1</span><span style="color: #9999ff;">:before</span>{
<span style="color: #006699;">content</span><span style="color: #555555;">:</span> attr(data<span style="color: #555555;">-</span><span style="color: #006699;">text</span>);
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #336666;">crimson</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
animation<span style="color: #555555;">:</span> animate <span style="color: #ff6600;">10s</span> linear infinite;
<span style="color: #006699;">border-right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#000</span>;
}
<span style="color: #006699;">@keyframes</span> <span style="color: #330099;">animate</span>{
<span style="color: #330099;">0</span><span style="color: #555555;">%</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #330099;">50</span><span style="color: #555555;">%</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span><span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
}
<span style="color: #330099;">100</span><span style="color: #555555;">%</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span><span style="color: #ff6600;">0</span>;
}
}</span>
</pre>
</div>
<br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-68170355675271100282019-07-22T11:17:00.000+08:002019-07-22T11:17:58.679+08:00Create Form Login Transparent HTML CSS<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-2zaXTetzI-k/W7CHxV-hvWI/AAAAAAAABXw/p3DjUSByM1YlmwLXZ-B_ji2Qr3NwHjPwQCLcBGAs/s1600/form%2Blogin%2Btransparent.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="738" data-original-width="1330" src="https://2.bp.blogspot.com/-2zaXTetzI-k/W7CHxV-hvWI/AAAAAAAABXw/p3DjUSByM1YlmwLXZ-B_ji2Qr3NwHjPwQCLcBGAs/s1600/form%2Blogin%2Btransparent.jpg" /></a></div>
<br />
<hr />
<br />
Hello guys, this tutorial I will create a login form with transparent style with the background, which consists of entering an email and password and the Sign In button. The login form is the initial display of an application that allows users to fill in a <b>username and password</b> to identify the validity of a user in a system.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now, create a project folder and create the <b>index.html and style.css</b> files in it and include the user <b>logo</b> and <b>image for the background</b>. When finished, open <b>index.html</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Transparent Login Form<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"loginBox"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><img</span> <span style="color: #330099;">src=</span><span style="color: #cc3300;">"user.png"</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"user"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h2></span>Login<span style="color: #330099;"></h2></span>
<span style="color: #330099;"><form></span>
<span style="color: #330099;"><p></span>Email<span style="color: #330099;"></p></span>
<span style="color: #330099;"><input</span> <span style="color: #330099;">type=</span><span style="color: #cc3300;">"text"</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">""</span> <span style="color: #330099;">placeholder=</span><span style="color: #cc3300;">"Enter Email"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><p></span>Password<span style="color: #330099;"></p></span>
<span style="color: #330099;"><input</span> <span style="color: #330099;">type=</span><span style="color: #cc3300;">"password"</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">""</span> <span style="color: #330099;">placeholder=</span><span style="color: #cc3300;">"******"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><input</span> <span style="color: #330099;">type=</span><span style="color: #cc3300;">"submit"</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">""</span> <span style="color: #330099;">value=</span><span style="color: #cc3300;">"Sign In"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>Forget Password<span style="color: #330099;"></a></span>
<span style="color: #330099;"></form></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
Next, open <b>style.css</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(bg.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #006699;">sans-serif</span>;
}
<span style="color: #00aa88;">.loginBox</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">350px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">420px</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> rgba(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">5</span>);
}
<span style="color: #00aa88;">.user</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100px</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> calc(<span style="color: #ff6600;">-100px</span><span style="color: #555555;">/</span><span style="color: #ff6600;">2</span>);
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> calc(<span style="color: #ff6600;">50</span><span style="color: #555555;">%</span> <span style="color: #555555;">-</span> <span style="color: #ff6600;">50px</span>);
}
<span style="color: #330099;">h2</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">20px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#efed40</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
}
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">p</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #006699;">bold</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
}
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">input</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">margin-bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
}
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">input</span><span style="color: #555555;">[</span><span style="color: #330099;">type</span><span style="color: #555555;">=</span><span style="color: #cc3300;">"text"</span><span style="color: #555555;">],</span>
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">input</span><span style="color: #555555;">[</span><span style="color: #330099;">type</span><span style="color: #555555;">=</span><span style="color: #cc3300;">"password"</span><span style="color: #555555;">]</span>{
<span style="color: #006699;">border</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">border-bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #006699;">transparent</span>;
<span style="color: #006699;">outline</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">16px</span>;
}
<span style="color: #555555;">:</span><span style="color: #9999ff;">:placeholder</span>{
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> rgba(<span style="color: #ff6600;">255</span><span style="color: #555555;">,</span><span style="color: #ff6600;">255</span><span style="color: #555555;">,</span><span style="color: #ff6600;">255</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">5</span>);
}
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">input</span><span style="color: #555555;">[</span><span style="color: #330099;">type</span><span style="color: #555555;">=</span><span style="color: #cc3300;">"submit"</span><span style="color: #555555;">]</span>{
<span style="color: #006699;">border</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">outline</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">16px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#ff267e</span>;
<span style="color: #006699;">cursor</span><span style="color: #555555;">:</span> <span style="color: #006699;">pointer</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
}
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">input</span><span style="color: #555555;">[</span><span style="color: #330099;">type</span><span style="color: #555555;">=</span><span style="color: #cc3300;">"submit"</span><span style="color: #555555;">]</span><span style="color: #9999ff;">:hover</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#efed40</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#262626</span>;
}
<span style="color: #00aa88;">.loginBox</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">14px</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #006699;">bold</span>;
<span style="color: #006699;">text-decoration</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
}</span>
</pre>
</div>
<br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-87300698583634207712019-07-08T13:23:00.000+08:002019-11-28T11:47:00.037+08:00Create Images Gallery Android Studio<div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-j63Pgo1nuxA/W2aprU0tcII/AAAAAAAABJA/w6Z_7E2SLBIxiONxms43k-JhSdzFUe2JQCLcBGAs/s1600/pexels-photo-1092644.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="627" data-original-width="940" src="https://2.bp.blogspot.com/-j63Pgo1nuxA/W2aprU0tcII/AAAAAAAABJA/w6Z_7E2SLBIxiONxms43k-JhSdzFUe2JQCLcBGAs/s1600/pexels-photo-1092644.jpeg" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://drive.google.com/uc?export=download&id=1treT2mLaz0UIgERGs43kLFHxBXyjn5_L" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="556" data-original-width="320" height="320" src="https://drive.google.com/uc?export=download&id=1treT2mLaz0UIgERGs43kLFHxBXyjn5_L" width="184" /></a></div><br />
Hello guys, in this post I will discuss Android again. Yupp, I will try to explain about how to create an image gallery application that has two views, the first is the grid model and the second with the slide model according to the picture above.<br />
<br />
Okay, first open Android Studio and create a new project. If it's ready, open it in the res> values> <b>colors.xml</b> and replace it with the following color (Optional)<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><resources></span>
<span style="color: #330099;"><color</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"colorPrimary"</span><span style="color: #330099;">></span>#00695C<span style="color: #330099;"></color></span>
<span style="color: #330099;"><color</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"colorPrimaryDark"</span><span style="color: #330099;">></span>#004D40<span style="color: #330099;"></color></span>
<span style="color: #330099;"><color</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"colorAccent"</span><span style="color: #330099;">></span>#ffffff<span style="color: #330099;"></color></span>
<span style="color: #330099;"></resources></span></span>
</pre></div><br />
Next, open the res> menu> <b>menu_main.xml</b> then replace it with the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><menu</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">xmlns:app=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res-auto"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><item</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/change"</span>
<span style="color: #330099;">android:orderInCategory=</span><span style="color: #cc3300;">"100"</span>
<span style="color: #330099;">android:title=</span><span style="color: #cc3300;">"Switch"</span>
<span style="color: #330099;">app:showAsAction=</span><span style="color: #cc3300;">"always"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"></menu></span></span>
</pre></div><br />
And here we need 3 layouts and 5 class :<br />
<ol><li>activity_main.xml</li>
<li>full_image.xml</li>
<li>grid_layout.xml</li>
</ol><div><ol><li>MainActivity.java</li>
<li>Adapter1.java</li>
<li>Adapter2.java</li>
<li>FullImage.java</li>
<li>galeri2.java</li>
</ol><div>Okay, if everything is ready, now open <b>activity_main.xml</b> and enter the following code</div></div><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;"><LinearLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">xmlns:tools=</span><span style="color: #cc3300;">"http://schemas.android.com/tools"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span>
<span style="color: #330099;">tools:context=</span><span style="color: #cc3300;">".MainActivity"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><ImageView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/selectedImageView"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"400dp"</span>
<span style="color: #330099;">android:scaleType=</span><span style="color: #cc3300;">"fitXY"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"><Gallery</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/simpleGallery"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span>
<span style="color: #330099;">android:layout_marginTop=</span><span style="color: #cc3300;">"40dp"</span>
<span style="color: #330099;">android:unselectedAlpha=</span><span style="color: #cc3300;">"50"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"></LinearLayout></span></span>
</pre></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Next, open <b>grid_layout.xml</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><GridView</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/grid_view"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:numColumns=</span><span style="color: #cc3300;">"auto_fit"</span>
<span style="color: #330099;">android:columnWidth=</span><span style="color: #cc3300;">"110dp"</span>
<span style="color: #330099;">android:padding=</span><span style="color: #cc3300;">"5dp"</span>
<span style="color: #330099;">android:verticalSpacing=</span><span style="color: #cc3300;">"10dp"</span>
<span style="color: #330099;">android:gravity=</span><span style="color: #cc3300;">"center"</span>
<span style="color: #330099;">android:stretchMode=</span><span style="color: #cc3300;">"columnWidth"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"@null"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></GridView></span></span>
</pre></div><br />
Next, open <b>full_image.xml</b> and enter the following code so that the image appears with a full screen<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="UTF-8"?></span>
<span style="color: #330099;"><LinearLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"#000000"</span> <span style="color: #330099;">></span>
<span style="color: #330099;"><ImageSwitcher</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/imageSwitcher"</span>
<span style="color: #330099;">android:layout_alignParentTop=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_centerHorizontal=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><ImageView</span> <span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/full_image_view"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"fill_parent"</span><span style="color: #330099;">/></span>
<span style="color: #330099;"></ImageSwitcher></span>
<span style="color: #330099;"></LinearLayout></span></span>
</pre></div><br />
When it's finished, we need to prepare some images in the <b>drawable</b> folder in our project, and here I use 13 images<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://3.bp.blogspot.com/--64fPinv8tU/W2agzp1zRiI/AAAAAAAABIs/mU97i9T2JfMmIGyIW3NebvY-rG5tyUvIwCLcBGAs/s1600/16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="319" data-original-width="1193" src="https://3.bp.blogspot.com/--64fPinv8tU/W2agzp1zRiI/AAAAAAAABIs/mU97i9T2JfMmIGyIW3NebvY-rG5tyUvIwCLcBGAs/s1600/16.png" /></a></div>If your image is ready, we move the class section, then open <b>Adapter1.java</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.content.Context</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.ViewGroup</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.BaseAdapter</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.GridView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.ImageView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">Adapter1</span> <span style="color: #006699;">extends</span> BaseAdapter <span style="color: #555555;">{</span>
<span style="color: #006699;">private</span> Context mContext<span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> Integer<span style="color: #555555;">[]</span> mThumbIds <span style="color: #555555;">=</span> <span style="color: #555555;">{</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img1</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img2</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img3</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img4</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img5</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img6</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img7</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img8</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img9</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img10</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img11</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img12</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img13</span>
<span style="color: #555555;">};</span>
<span style="color: #006699;">public</span> <span style="color: #cc00ff;">Adapter1</span><span style="color: #555555;">(</span>Context c<span style="color: #555555;">){</span>
mContext <span style="color: #555555;">=</span> c<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">int</span> <span style="color: #cc00ff;">getCount</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> mThumbIds<span style="color: #555555;">.</span><span style="color: #330099;">length</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> Object <span style="color: #cc00ff;">getItem</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> position<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> mThumbIds<span style="color: #555555;">[</span>position<span style="color: #555555;">];</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">long</span> <span style="color: #cc00ff;">getItemId</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> position<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> <span style="color: #ff6600;">0</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> View <span style="color: #cc00ff;">getView</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> position<span style="color: #555555;">,</span> View convertView<span style="color: #555555;">,</span> ViewGroup parent<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
ImageView imageView <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> ImageView<span style="color: #555555;">(</span>mContext<span style="color: #555555;">);</span>
imageView<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>mThumbIds<span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
imageView<span style="color: #555555;">.</span><span style="color: #330099;">setScaleType</span><span style="color: #555555;">(</span>ImageView<span style="color: #555555;">.</span><span style="color: #330099;">ScaleType</span><span style="color: #555555;">.</span><span style="color: #330099;">CENTER_INSIDE</span><span style="color: #555555;">);</span>
imageView<span style="color: #555555;">.</span><span style="color: #330099;">setLayoutParams</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> GridView<span style="color: #555555;">.</span><span style="color: #330099;">LayoutParams</span><span style="color: #555555;">(</span><span style="color: #ff6600;">200</span><span style="color: #555555;">,</span> <span style="color: #ff6600;">200</span><span style="color: #555555;">));</span>
<span style="color: #006699;">return</span> imageView<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre></div><br />
Next, open <b>Adapter2.java</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.content.Context</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.ViewGroup</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.BaseAdapter</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.Gallery</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.ImageView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">Adapter2</span> <span style="color: #006699;">extends</span> BaseAdapter <span style="color: #555555;">{</span>
<span style="color: #006699;">private</span> Context context<span style="color: #555555;">;</span>
<span style="color: #006699;">private</span> <span style="color: #007788;">int</span><span style="color: #555555;">[]</span> images<span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #cc00ff;">Adapter2</span><span style="color: #555555;">(</span>Context c<span style="color: #555555;">,</span> <span style="color: #007788;">int</span><span style="color: #555555;">[]</span> images<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
context <span style="color: #555555;">=</span> c<span style="color: #555555;">;</span>
<span style="color: #006699;">this</span><span style="color: #555555;">.</span><span style="color: #330099;">images</span> <span style="color: #555555;">=</span> images<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">int</span> <span style="color: #cc00ff;">getCount</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> images<span style="color: #555555;">.</span><span style="color: #330099;">length</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">public</span> Object <span style="color: #cc00ff;">getItem</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> position<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> position<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">long</span> <span style="color: #cc00ff;">getItemId</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> position<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> position<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">public</span> View <span style="color: #cc00ff;">getView</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> position<span style="color: #555555;">,</span> View convertView<span style="color: #555555;">,</span> ViewGroup parent<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
ImageView imageView <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> ImageView<span style="color: #555555;">(</span>context<span style="color: #555555;">);</span>
imageView<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>images<span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
imageView<span style="color: #555555;">.</span><span style="color: #330099;">setLayoutParams</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> Gallery<span style="color: #555555;">.</span><span style="color: #330099;">LayoutParams</span><span style="color: #555555;">(</span><span style="color: #ff6600;">200</span><span style="color: #555555;">,</span> <span style="color: #ff6600;">200</span><span style="color: #555555;">));</span>
<span style="color: #006699;">return</span> imageView<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre></div><br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
We move to <b>FullImage.java</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.app.Activity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.content.Intent</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.MotionEvent</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.ImageSwitcher</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.ImageView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.Toast</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">FullImage</span> <span style="color: #006699;">extends</span> Activity <span style="color: #555555;">{</span>
ImageSwitcher Switch<span style="color: #555555;">;</span>
ImageView images<span style="color: #555555;">;</span>
<span style="color: #007788;">float</span> initialX<span style="color: #555555;">;</span>
Adapter1 imageAdapter<span style="color: #555555;">;</span>
<span style="color: #006699;">private</span> <span style="color: #007788;">int</span> position <span style="color: #555555;">;</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">full_image</span><span style="color: #555555;">);</span>
Switch <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>ImageSwitcher<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">imageSwitcher</span><span style="color: #555555;">);</span>
Intent i <span style="color: #555555;">=</span> getIntent<span style="color: #555555;">();</span>
position <span style="color: #555555;">=</span> i<span style="color: #555555;">.</span><span style="color: #330099;">getExtras</span><span style="color: #555555;">().</span><span style="color: #330099;">getInt</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"id"</span><span style="color: #555555;">);</span>
imageAdapter <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> Adapter1<span style="color: #555555;">(</span><span style="color: #006699;">this</span><span style="color: #555555;">);</span>
images <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>ImageView<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">full_image_view</span><span style="color: #555555;">);</span>
images<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">onTouchEvent</span><span style="color: #555555;">(</span>MotionEvent event<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">switch</span> <span style="color: #555555;">(</span>event<span style="color: #555555;">.</span><span style="color: #330099;">getAction</span><span style="color: #555555;">())</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">case</span> MotionEvent<span style="color: #555555;">.</span><span style="color: #330099;">ACTION_DOWN</span><span style="color: #555555;">:</span>
initialX <span style="color: #555555;">=</span> event<span style="color: #555555;">.</span><span style="color: #330099;">getX</span><span style="color: #555555;">();</span>
<span style="color: #006699;">break</span><span style="color: #555555;">;</span>
<span style="color: #006699;">case</span> MotionEvent<span style="color: #555555;">.</span><span style="color: #330099;">ACTION_UP</span><span style="color: #555555;">:</span>
<span style="color: #007788;">float</span> finalX <span style="color: #555555;">=</span> event<span style="color: #555555;">.</span><span style="color: #330099;">getX</span><span style="color: #555555;">();</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">(</span>initialX <span style="color: #555555;">></span> finalX<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">(</span>position <span style="color: #555555;">==</span> imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">.</span><span style="color: #330099;">length</span><span style="color: #555555;">-</span><span style="color: #ff6600;">1</span><span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
position <span style="color: #555555;">=</span> <span style="color: #ff6600;">0</span><span style="color: #555555;">;</span>
images<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">[</span><span style="color: #ff6600;">0</span><span style="color: #555555;">]);</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>getApplicationContext<span style="color: #555555;">(),</span> <span style="color: #cc3300;">"First Image"</span><span style="color: #555555;">,</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
Switch<span style="color: #555555;">.</span><span style="color: #330099;">showPrevious</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span> <span style="color: #006699;">else</span> <span style="color: #555555;">{</span>
position<span style="color: #555555;">++;</span>
images<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>getApplicationContext<span style="color: #555555;">(),</span> <span style="color: #cc3300;">"Next Image"</span><span style="color: #555555;">,</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
Switch<span style="color: #555555;">.</span><span style="color: #330099;">showNext</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">else</span>
<span style="color: #555555;">{</span>
<span style="color: #006699;">if</span><span style="color: #555555;">(</span>position <span style="color: #555555;">></span> <span style="color: #ff6600;">0</span><span style="color: #555555;">)</span>
<span style="color: #555555;">{</span>
position<span style="color: #555555;">=</span> position<span style="color: #555555;">-</span><span style="color: #ff6600;">1</span><span style="color: #555555;">;</span>
images<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>getApplicationContext<span style="color: #555555;">(),</span> <span style="color: #cc3300;">"Previous Image"</span><span style="color: #555555;">,</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
Switch<span style="color: #555555;">.</span><span style="color: #330099;">showPrevious</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">else</span>
<span style="color: #555555;">{</span>
position <span style="color: #555555;">=</span> imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">.</span><span style="color: #330099;">length</span><span style="color: #555555;">-</span><span style="color: #ff6600;">1</span><span style="color: #555555;">;</span>
images<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>imageAdapter<span style="color: #555555;">.</span><span style="color: #330099;">mThumbIds</span><span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span>getApplicationContext<span style="color: #555555;">(),</span> <span style="color: #cc3300;">"Last Image"</span><span style="color: #555555;">,</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
Switch<span style="color: #555555;">.</span><span style="color: #330099;">showPrevious</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">break</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">false</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre></div><br />
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-5403872783527179"
data-ad-slot="1797650250"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now, open <b>MainActivity.java</b> then enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.content.Intent</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v7.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.Menu</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.MenuItem</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.AdapterView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.Gallery</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.ImageView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MainActivity</span> <span style="color: #006699;">extends</span> AppCompatActivity <span style="color: #555555;">{</span>
Gallery simpleGallery<span style="color: #555555;">;</span>
Adapter2 customGalleryAdapter<span style="color: #555555;">;</span>
ImageView selectedImageView<span style="color: #555555;">;</span>
<span style="color: #007788;">int</span><span style="color: #555555;">[]</span> images <span style="color: #555555;">=</span> <span style="color: #555555;">{</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img1</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img2</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img3</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img4</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img5</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img6</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img7</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img8</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img9</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img10</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img11</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img12</span><span style="color: #555555;">,</span>
R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">img13</span><span style="color: #555555;">};</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">protected</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">activity_main</span><span style="color: #555555;">);</span>
simpleGallery <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>Gallery<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">simpleGallery</span><span style="color: #555555;">);</span>
selectedImageView <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>ImageView<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">selectedImageView</span><span style="color: #555555;">);</span>
customGalleryAdapter <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> Adapter2<span style="color: #555555;">(</span>getApplicationContext<span style="color: #555555;">(),</span> images<span style="color: #555555;">);</span>
simpleGallery<span style="color: #555555;">.</span><span style="color: #330099;">setAdapter</span><span style="color: #555555;">(</span>customGalleryAdapter<span style="color: #555555;">);</span>
selectedImageView<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>images<span style="color: #555555;">[</span><span style="color: #ff6600;">0</span><span style="color: #555555;">]);</span>
simpleGallery<span style="color: #555555;">.</span><span style="color: #330099;">setOnItemClickListener</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> AdapterView<span style="color: #555555;">.</span><span style="color: #330099;">OnItemClickListener</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onItemClick</span><span style="color: #555555;">(</span>AdapterView<span style="color: #555555;"><?></span> parent<span style="color: #555555;">,</span> View view<span style="color: #555555;">,</span> <span style="color: #007788;">int</span> position<span style="color: #555555;">,</span> <span style="color: #007788;">long</span> id<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
selectedImageView<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>images<span style="color: #555555;">[</span>position<span style="color: #555555;">]);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">});</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">onCreateOptionsMenu</span><span style="color: #555555;">(</span>Menu menu<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
getMenuInflater<span style="color: #555555;">().</span><span style="color: #330099;">inflate</span><span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">menu</span><span style="color: #555555;">.</span><span style="color: #330099;">menu_main</span><span style="color: #555555;">,</span> menu<span style="color: #555555;">);</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">onOptionsItemSelected</span><span style="color: #555555;">(</span>MenuItem item<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #007788;">int</span> id <span style="color: #555555;">=</span> item<span style="color: #555555;">.</span><span style="color: #330099;">getItemId</span><span style="color: #555555;">();</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">(</span>id <span style="color: #555555;">==</span> R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">change</span><span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
startActivity<span style="color: #555555;">(</span><span style="color: #006699;">new</span> Intent<span style="color: #555555;">(</span>MainActivity<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span>galeri2<span style="color: #555555;">.</span><span style="color: #330099;">class</span><span style="color: #555555;">));</span>
finish<span style="color: #555555;">();</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onOptionsItemSelected</span><span style="color: #555555;">(</span>item<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre></div><br />
And finally, open <b>galeri2.java</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.content.Intent</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v7.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.Menu</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.MenuItem</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.AdapterView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.GridView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">galeri2</span> <span style="color: #006699;">extends</span> AppCompatActivity <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">protected</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">grid_layout</span><span style="color: #555555;">);</span>
GridView gridView <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>GridView<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">grid_view</span><span style="color: #555555;">);</span>
gridView<span style="color: #555555;">.</span><span style="color: #330099;">setAdapter</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> Adapter1<span style="color: #555555;">(</span><span style="color: #006699;">this</span><span style="color: #555555;">));</span>
gridView<span style="color: #555555;">.</span><span style="color: #330099;">setOnItemClickListener</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> AdapterView<span style="color: #555555;">.</span><span style="color: #330099;">OnItemClickListener</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onItemClick</span><span style="color: #555555;">(</span>AdapterView<span style="color: #555555;"><?></span> parent<span style="color: #555555;">,</span> View v<span style="color: #555555;">,</span> <span style="color: #007788;">int</span> position<span style="color: #555555;">,</span> <span style="color: #007788;">long</span> id<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
Intent i <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> Intent<span style="color: #555555;">(</span>getApplicationContext<span style="color: #555555;">(),</span> FullImage<span style="color: #555555;">.</span><span style="color: #330099;">class</span><span style="color: #555555;">);</span>
i<span style="color: #555555;">.</span><span style="color: #330099;">putExtra</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"id"</span><span style="color: #555555;">,</span> position<span style="color: #555555;">);</span>
startActivity<span style="color: #555555;">(</span>i<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">});</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">onCreateOptionsMenu</span><span style="color: #555555;">(</span>Menu menu<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
getMenuInflater<span style="color: #555555;">().</span><span style="color: #330099;">inflate</span><span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">menu</span><span style="color: #555555;">.</span><span style="color: #330099;">menu_main</span><span style="color: #555555;">,</span> menu<span style="color: #555555;">);</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">onOptionsItemSelected</span><span style="color: #555555;">(</span>MenuItem item<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #007788;">int</span> id <span style="color: #555555;">=</span> item<span style="color: #555555;">.</span><span style="color: #330099;">getItemId</span><span style="color: #555555;">();</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">(</span>id <span style="color: #555555;">==</span> R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">change</span><span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
startActivity<span style="color: #555555;">(</span><span style="color: #006699;">new</span> Intent<span style="color: #555555;">(</span>galeri2<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span>MainActivity<span style="color: #555555;">.</span><span style="color: #330099;">class</span><span style="color: #555555;">));</span>
finish<span style="color: #555555;">();</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onOptionsItemSelected</span><span style="color: #555555;">(</span>item<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre></div><br />
If there is no error here, the last step is to open manifests.xml and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><manifest</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">package=</span><span style="color: #cc3300;">"your package"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><uses-permission</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.permission.WRITE_EXTERNAL_STORAGE"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"><application</span>
<span style="color: #330099;">android:allowBackup=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:icon=</span><span style="color: #cc3300;">"@mipmap/ic_launcher"</span>
<span style="color: #330099;">android:label=</span><span style="color: #cc3300;">"By Ndiappink"</span>
<span style="color: #330099;">android:supportsRtl=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:theme=</span><span style="color: #cc3300;">"@style/AppTheme"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><activity</span>
<span style="color: #330099;">android:name=</span><span style="color: #cc3300;">".MainActivity"</span>
<span style="color: #330099;">android:label=</span><span style="color: #cc3300;">"@string/app_name"</span>
<span style="color: #330099;">android:theme=</span><span style="color: #cc3300;">"@style/AppTheme"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><intent-filter></span>
<span style="color: #330099;"><action</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.intent.action.MAIN"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"><category</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.intent.category.LAUNCHER"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"></intent-filter></span>
<span style="color: #330099;"></activity></span>
<span style="color: #330099;"><activity</span>
<span style="color: #330099;">android:name=</span><span style="color: #cc3300;">".FullImage"</span>
<span style="color: #330099;">android:label=</span><span style="color: #cc3300;">"@string/app_name"</span>
<span style="color: #330099;">android:theme=</span><span style="color: #cc3300;">"@style/AppTheme"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></activity></span>
<span style="color: #330099;"><activity</span>
<span style="color: #330099;">android:name=</span><span style="color: #cc3300;">".galeri2"</span>
<span style="color: #330099;">android:label=</span><span style="color: #cc3300;">"@string/app_name"</span>
<span style="color: #330099;">android:theme=</span><span style="color: #cc3300;">"@style/AppTheme"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></activity></span>
<span style="color: #330099;"></application></span>
<span style="color: #330099;"></manifest></span></span>
</pre></div><br />
Okay, now the program is ready to run.Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-66769393767587863722019-05-22T16:16:00.001+08:002019-05-22T16:16:57.384+08:00Image Hover CSS Effects<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-ss4vfkxeK5M/W64XuDLq-9I/AAAAAAAABTg/gmKAHzs4d0A7MM2e_ExQXPEUB9fQnZgdACLcBGAs/s1600/Image%2BHover%2BEffect.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="375" data-original-width="700" src="https://1.bp.blogspot.com/-ss4vfkxeK5M/W64XuDLq-9I/AAAAAAAABTg/gmKAHzs4d0A7MM2e_ExQXPEUB9fQnZgdACLcBGAs/s1600/Image%2BHover%2BEffect.jpg" /></a></div>
<br />
<hr />
<br />
<h2>
Preview</h2>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://drive.google.com/uc?export=download&id=1S0gDiYYZqxQ058NeIQMs-v-51iqAJ1gk" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1S0gDiYYZqxQ058NeIQMs-v-51iqAJ1gk" width="320" /></a></div>
<br />
<br />
Okay, on this occasion I will make a hover effect on an image. So this tutorial we will learn to create a rotation effect accompanied by a caption on an image when highlighted by the mouse pointer or by the term <b>Hover</b><br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
First create a project folder, and create the <b>index.html</b> and<b> style.css</b> files in it, and include one image in landscape mode. When finished, open index.html and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Menu Hover Effect<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"box"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"model"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><img</span> <span style="color: #330099;">src=</span><span style="color: #cc3300;">"img.jpg"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"caption"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"about"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h2></span>Image Hover Effect<span style="color: #330099;"></h2></span>
<span style="color: #330099;"><p></span>There are many variations of passages of Lorem Ipsum available, but the
majority have suffered alteration in some form, by injected humour,
or randomised words which don't look even slightly believable.
<span style="color: #330099;"></p></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
Open the <b>style.css </b>then enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>
{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#f5f5f5</span>;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">'Roboto'</span><span style="color: #555555;">,</span><span style="color: #006699;">sans-serif</span>;
}
<span style="color: #00aa88;">.box</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">700px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">375px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#000</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
}
<span style="color: #00aa88;">.model</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
}
<span style="color: #00aa88;">.model</span> <span style="color: #330099;">img</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
}
<span style="color: #00aa88;">.box</span><span style="color: #9999ff;">:hover</span> <span style="color: #00aa88;">.model</span> <span style="color: #330099;">img</span>{
transform<span style="color: #555555;">:</span> rotate(<span style="color: #ff6600;">-10</span>deg) scale(<span style="color: #ff6600;">1</span><span style="color: #555555;">.</span><span style="color: #ff6600;">3</span>);
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #555555;">.</span><span style="color: #ff6600;">5</span>;
}
<span style="color: #00aa88;">.caption</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
}
<span style="color: #00aa88;">.caption</span><span style="color: #9999ff;">:before</span>{
<span style="color: #006699;">content</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">''</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">border-top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">border-bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#fff</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
transform<span style="color: #555555;">:</span> scale(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">1</span>);
}
<span style="color: #00aa88;">.box</span><span style="color: #9999ff;">:hover</span> <span style="color: #00aa88;">.caption</span><span style="color: #9999ff;">:before</span>{
transform<span style="color: #555555;">:</span> scale(<span style="color: #ff6600;">1</span><span style="color: #555555;">,</span><span style="color: #ff6600;">1</span>);
}
<span style="color: #00aa88;">.caption</span><span style="color: #9999ff;">:after</span>{
<span style="color: #006699;">content</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">''</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">border-left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">border-right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#fff</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
transform<span style="color: #555555;">:</span> scale(<span style="color: #ff6600;">1</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span>);
}
<span style="color: #00aa88;">.box</span><span style="color: #9999ff;">:hover</span> <span style="color: #00aa88;">.caption</span><span style="color: #9999ff;">:after</span>{
transform<span style="color: #555555;">:</span> scale(<span style="color: #ff6600;">1</span><span style="color: #555555;">,</span><span style="color: #ff6600;">1</span>);
}
<span style="color: #00aa88;">.about</span>{
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
transform<span style="color: #555555;">:</span> scale(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">1</span>);
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translateY(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">z-index</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
}
<span style="color: #00aa88;">.about</span> <span style="color: #330099;">h2</span>{
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
}
<span style="color: #00aa88;">.about</span> <span style="color: #330099;">p</span>{
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">16px</span>;
}</span>
</pre>
</div>
<br />
Save all files, and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-61337031949151661472019-05-04T19:39:00.001+08:002019-05-04T19:39:28.846+08:00Create Landing Page Free HTML CSS<br />
Hello friends, in this post I will create a simple Landing Page using <b>HTML and CSS</b><br />
<br />
Landing Page is a website page that is first visited by visitors. If the landing page you make is more attractive, the more users will visit your website, and of course this will make your website traffic higher and your income will increase.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
And in this tutorial I will give a simple landing page example, but it still looks elegant like the screenshot below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-rImtt5dXJ5k/W4DH7wPhbPI/AAAAAAAABPA/QuYHi4RR_3k7pVdJdDBh57eb86x-ytytgCLcBGAs/s1600/19.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="652" data-original-width="1366" src="https://1.bp.blogspot.com/-rImtt5dXJ5k/W4DH7wPhbPI/AAAAAAAABPA/QuYHi4RR_3k7pVdJdDBh57eb86x-ytytgCLcBGAs/s1600/19.jpg" /></a></div>
<br />
<br />
Before that I needed to prepare two images as background and as a logo that I saved in the <b>img</b> folder in my project.<br />
<span style="background-color: white; color: #222222; font-size: 16px;"><span style="font-family: inherit;"><br />
</span></span> <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-UOS1Y-xsV5k/W4DF7otXgeI/AAAAAAAABO0/Fa0YRnCHB10uQaMBH6rxdJZIl5pNE9tAQCLcBGAs/s1600/18.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="222" data-original-width="449" src="https://1.bp.blogspot.com/-UOS1Y-xsV5k/W4DF7otXgeI/AAAAAAAABO0/Fa0YRnCHB10uQaMBH6rxdJZIl5pNE9tAQCLcBGAs/s1600/18.jpg" /></a></div>
<div class="separator" style="clear: both;">
Now, open your favorite text editor, then create the <b>index.html</b> and <b>style.css</b> files save in the same folder as the <b>"img"</b> folder</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Now, open the<b> index.html</b> file and enter the following code</div>
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Landing Page<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"container"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><nav></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"logo"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"index.html"</span><span style="color: #330099;">><img</span> <span style="color: #330099;">src=</span><span style="color: #cc3300;">"img/NM.png"</span><span style="color: #330099;">></a></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><ul></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#about-us"</span><span style="color: #330099;">></span>contact us<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#review-movie"</span><span style="color: #330099;">></span>reviews<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#watch-movie"</span><span style="color: #330099;">></span>watch now<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#genre-movie"</span><span style="color: #330099;">></span>genre<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>login<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"></ul></span>
<span style="color: #330099;"></nav></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"deskripsi"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><img</span> <span style="color: #330099;">src=</span><span style="color: #cc3300;">"img/NM.png"</span><span style="color: #330099;">><br><br></span>
<span style="color: #330099;"><p></span>
CHANGE YOUR DESK INTO CINEMA
<span style="color: #330099;"><P></span>MORE THAN ONE MILLION MOVIE WITH HD QUALITY<span style="color: #330099;"></P></span>
<span style="color: #330099;"></p></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#genre-movie"</span><span style="color: #330099;">><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-angle-double-down"</span><span style="color: #330099;">></i></a></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
the above code consists of:<br />
<ol>
<li>Nav Bar inside is a navigation menu and logo</li>
<li>Banner background with a brief description and logo</li>
<li>The down arrow button for the page below it</li>
</ol>
<div>
Now, open the <b>style.css</b> file and enter the following code</div>
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">html</span><span style="color: #555555;">,</span>
<span style="color: #555555;">*</span>{
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
}
<span style="color: #330099;">body</span> {
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background-image</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(img/bg.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">'Roboto'</span><span style="color: #555555;">,</span> <span style="color: #006699;">sans-serif</span>;
}
<span style="color: #00aa88;">.container</span> {
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #006699;">auto</span>;
}
<span style="color: #00aa88;">.container</span> {
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #006699;">auto</span>;
}
<span style="color: #330099;">nav</span> {
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">70px</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
}
<span style="color: #330099;">nav</span> <span style="color: #00aa88;">.logo</span> {
<span style="color: #006699;">float</span><span style="color: #555555;">:</span> <span style="color: #006699;">left</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">17px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">15px</span>;
<span style="color: #006699;">margin-left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #006699;">bold</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">5px</span>;
}
<span style="color: #00aa88;">.logo</span> <span style="color: #330099;">img</span>{
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">5px</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">120px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
}
<span style="color: #330099;">nav</span> <span style="color: #330099;">ul</span> {
<span style="color: #006699;">float</span><span style="color: #555555;">:</span> <span style="color: #006699;">right</span>;
<span style="color: #006699;">list-style</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">margin-right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
}
<span style="color: #330099;">nav</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> {
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">inline</span><span style="color: #555555;">-</span>flex;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">5px</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">15px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">6px</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
}
<span style="color: #330099;">nav</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span> {
<span style="color: #006699;">text-decoration</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span> <span style="color: #ff6600;">20px</span>;
}
<span style="color: #330099;">nav</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover</span> {
<span style="color: #006699;">background-color</span><span style="color: #555555;">:</span> <span style="color: #336666;">crimson</span>;
}
<span style="color: #330099;">nav</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">5</span><span style="color: #555555;">)</span> {
<span style="color: #006699;">background-color</span><span style="color: #555555;">:</span> <span style="color: #336666;">crimson</span>;
}
<span style="color: #00aa88;">.deskripsi</span> {
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span><span style="color: #ff6600;">45</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">68</span><span style="color: #555555;">%</span> ;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">200px</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> calc(<span style="color: #ff6600;">50</span><span style="color: #555555;">%</span> <span style="color: #555555;">-</span> <span style="color: #ff6600;">22</span><span style="color: #555555;">.</span><span style="color: #ff6600;">5</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
}
<span style="color: #00aa88;">.deskripsi</span> <span style="color: #330099;">i</span><span style="color: #9999ff;">:hover</span>{
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1</span>;
}
<span style="color: #00aa88;">.deskripsi</span> <span style="color: #330099;">i</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #555555;">.</span><span style="color: #ff6600;">5</span>;
<span style="color: #006699;">text-decoration</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
}
<span style="color: #00aa88;">.deskripsi</span> <span style="color: #330099;">h1</span> {
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">'Raleway'</span><span style="color: #555555;">,</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1000</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">90px</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">10px</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
}
<span style="color: #00aa88;">.deskripsi</span> <span style="color: #330099;">p</span> {
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #006699;">auto</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">15px</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">3px</span>;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">'Roboto'</span><span style="color: #555555;">,</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#f5f5f5</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #00aa88;">.deskripsi</span> <span style="color: #330099;">img</span> {
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #555555;">.</span><span style="color: #ff6600;">9</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">600px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">150px</span>;
}</span>
</pre>
</div>
<br />
Save all files and run the<b> index.html</b> file.<br />
<br />Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-89693287331046786642019-02-28T13:10:00.000+08:002019-02-28T13:10:26.454+08:00How To Insert Data In VB.Net<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-eviZaPK0_-8/W2V5anSFisI/AAAAAAAABHA/DjlZkjLmqn45FaldZWzRpTCNN8tKWlTGgCLcBGAs/s1600/INSERT%2BWITH%2BDGV.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="410" data-original-width="960" src="https://3.bp.blogspot.com/-eviZaPK0_-8/W2V5anSFisI/AAAAAAAABHA/DjlZkjLmqn45FaldZWzRpTCNN8tKWlTGgCLcBGAs/s1600/INSERT%2BWITH%2BDGV.jpg" /></a></div>
<style type="text/css">
@media only screen and (max-width: 340px) {
.w3-example {
background-color: #fff;
padding: 4px 14px 19px 10px;
margin-left: 3px;
margin-right: 3px;
border-radius: 15px;
width: auto;
height: 80px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)!important;
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
}
@media only screen and (max-width: 480px) {
.w3-example {
background-color: #fff;
padding: 4px 14px 19px 10px;
margin-left: 3px;
margin-right: 3px;
border-radius: 15px;
width: auto;
height: 80px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)!important;
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
}
.w3-example {
background-color: #fff;
padding: 3px 16px;
margin-left: 3px;
margin-right: 3px;
border-radius: 15px;
width: auto;
height: 80px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)!important;
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
.w3-example:hover {
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)!important;
}
html, body {
font-family: Montserrat;
font-size: 10px;
}
h2 {
display: block;
font-size: 20px;
font-weight: bold;
}
</style><br />
<br />
<hr />
<br />
<h2>
Preview</h2>
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://drive.google.com/uc?export=download&id=1vQG8XBlMfcP1uOKEUXl5Z2QrAzMR4PBC" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="203" src="https://drive.google.com/uc?export=download&id=1vQG8XBlMfcP1uOKEUXl5Z2QrAzMR4PBC" width="320" /></a></div>
<br />
Hello friends, in this post I will discuss about storing data into a database without using a textbox to fill all data, but only using <b>DataGridView</b> and one button in Visual Studio 2010.<br />
<br />
Okay, and here I have a database called "tes" and a table named "pegawai" using SQL Server 2008.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-7G-L4k43FVo/W2VuEemre_I/AAAAAAAABGY/tef_UJimBO0WIebOSvoHSmIp8hYps8BTwCLcBGAs/s1600/10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="299" data-original-width="837" src="https://1.bp.blogspot.com/-7G-L4k43FVo/W2VuEemre_I/AAAAAAAABGY/tef_UJimBO0WIebOSvoHSmIp8hYps8BTwCLcBGAs/s1600/10.png" /></a></div>
<br />
Then create a Module to make a connection and declare the global variables needed<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Data.SqlClient</span>
<span style="color: #006699;">Module</span> <span style="color: #00ccff;">koneksi</span>
<span style="color: #006699;">Public</span> conn <span style="color: black;">As</span> SqlConnection
<span style="color: #006699;">Public</span> da <span style="color: black;">As</span> SqlDataAdapater
<span style="color: #006699;">Public</span> ds <span style="color: black;">As</span> <span style="color: #006699;">New</span> DataSet
<span style="color: #006699;">Public</span> cmd <span style="color: black;">As</span> SqlCommand
<span style="color: #006699;">Public</span> build <span style="color: black;">As</span> SqlCommandBuilder
<span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">koneksinya</span>()
<span style="color: #006699;">Dim</span> str <span style="color: black;">As</span> <span style="color: #007788;">String</span> <span style="color: #555555;">=</span> <span style="color: #cc3300;">"Data Source=ndiappink-pc\sqlexpress;Initial Catalog=tes;Integrated Security=True"</span>
conn <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> SqlConnection(str)
<span style="color: #006699;">If</span> conn.State <span style="color: #555555;">=</span> Connection.Closed <span style="color: #006699;">Then</span>
conn.Open()
<span style="color: #006699;">End</span> <span style="color: #006699;">If</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Module</span></span>
</pre>
</div>
<br />
If you need help on how to make a connection with SQL Server, read the article below<br />
<br />
<div class="w3-example">
<h5 style="color: red;">
MORE ARTICLE</h5>
<h2 align="center" style="color: blue;">
<a href="https://www.tutscode.net/2018/05/how-to-create-connection-visual-studio.html" style="text-decoration: none;" target="_blank">Create Connection With SQL Server 2008 (VB.Net)</a></h2>
</div>
<br />
Next we open Form1 and add DataGridView and Button as shown below<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-GeTD-SFkGus/W2Vz_JWw9zI/AAAAAAAABGs/9GMUuF3Q21UXplD6emg7sK6ZArzUG9cpwCLcBGAs/s1600/11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="265" data-original-width="657" src="https://3.bp.blogspot.com/-GeTD-SFkGus/W2Vz_JWw9zI/AAAAAAAABGs/9GMUuF3Q21UXplD6emg7sK6ZArzUG9cpwCLcBGAs/s1600/11.png" /></a></div>
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Then, double-click Form1 (Sorry, my project is Form2: D) and enter the following code to display the data in the "pegawai" table into the DataGridView<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Imports</span> <span style="color: #00ccff;">System.Data.SqlClient</span>
<span style="color: #006699;">Public</span> <span style="color: #006699;">Class</span> <span style="color: #00aa88;">Form1</span>
<span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">Form1_Load</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.EventArgs) <span style="color: #006699;">Handles</span> <span style="color: #006699;">MyBase</span>.Load
<span style="color: #006699;">Call</span> koneksinya()
da <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> SqlDataAdapter(<span style="color: #cc3300;">"select kode as KODE, nama as NAMA, alamat as ALAMAT, hp as TEEPON, jabatan as JABATAN from pegawai"</span>, conn)
ds <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> DataSet
da.Fill(ds)
DataGridView.DataSource <span style="color: #555555;">=</span> ds.Tables(<span style="color: #ff6600;">0</span>)
DataGridView.Columns(<span style="color: #cc3300;">"KODE"</span>).Width <span style="color: #555555;">=</span> <span style="color: #ff6600;">50</span>
DataGridView.Columns(<span style="color: #cc3300;">"NAMA"</span>).Width <span style="color: #555555;">=</span> <span style="color: #ff6600;">150</span>
DataGridView.Columns(<span style="color: #cc3300;">"ALAMAT"</span>).Width <span style="color: #555555;">=</span> <span style="color: #ff6600;">150</span>
DataGridView.Columns(<span style="color: #cc3300;">"TELEPON"</span>).Width <span style="color: #555555;">=</span> <span style="color: #ff6600;">100</span>
DataGridView.Columns(<span style="color: #cc3300;">"JABATAN"</span>).Width <span style="color: #555555;">=</span> <span style="color: #ff6600;">150</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span>
<span style="color: #006699;">End</span> <span style="color: #006699;">CLass</span></span>
</pre>
</div>
<br />
Now, double-click Button1 and enter the following code for the data storage process in the database<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">Private</span> <span style="color: #006699;">Sub</span> <span style="color: #cc00ff;">Button1_Click</span>(<span style="color: #006699;">ByVal</span> sender <span style="color: black;">As</span> System.Object, <span style="color: #006699;">ByVal</span> e <span style="color: black;">As</span> System.EventArgs) <span style="color: #006699;">Handles</span> Button1.Click
<span style="color: #006699;">Call</span> koneksinya()
build <span style="color: #555555;">=</span> <span style="color: #006699;">New</span> SqlCommandBuilder(da)
da.Update(ds)
MsgBox(<span style="color: #cc3300;">"Data Has Been Inserted"</span>)
<span style="color: #006699;">End</span> <span style="color: #006699;">Sub</span></span>
</pre>
</div>
<br />
When finished, the project is ready to run. So, we just need to enter data in the DataGridView then click Button1<br />
<br />
<h3>
For more details, please watch the video below</h3>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/HjWRpwnb-S0/0.jpg" frameborder="0" height="370" src="https://www.youtube.com/embed/HjWRpwnb-S0?feature=player_embedded" width="100%"></iframe></div>
<div>
<br /></div>
Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-51968781854705120002019-02-15T06:48:00.001+08:002019-02-15T06:48:30.869+08:00How To Display Webview In Android<br />
Hello everyone, in this post I will discuss how to display a website using <b>WebView</b> on Android Studio.<br />
<br />
Okay, as usual for a new project, then open <b>activity_main.xml</b> and enter the following code to define the WebView component.<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><RelativeLayout</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span>
<span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><WebView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/webView"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></WebView></span>
<span style="color: #330099;"></RelativeLayout></span></span>
</pre>
</div>
<br />
Then, open <b>MainActivity.java</b> then enter the following code to define the WebView component and then display our website.<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v7.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.KeyEvent</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.webkit.WebView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.webkit.WebViewClient</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MainActivity</span> <span style="color: #006699;">extends</span> AppCompatActivity <span style="color: #555555;">{</span>
WebView view<span style="color: #555555;">;</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">protected</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">activity_main</span><span style="color: #555555;">);</span>
view <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>WebView<span style="color: #555555;">)</span> <span style="color: #006699;">this</span><span style="color: #555555;">.</span><span style="color: #330099;">findViewById</span><span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">webView</span><span style="color: #555555;">);</span>
view<span style="color: #555555;">.</span><span style="color: #330099;">getSettings</span><span style="color: #555555;">().</span><span style="color: #330099;">setJavaScriptEnabled</span><span style="color: #555555;">(</span><span style="color: #006699;">true</span><span style="color: #555555;">);</span>
view<span style="color: #555555;">.</span><span style="color: #330099;">setWebViewClient</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> MyBrowser<span style="color: #555555;">());</span>
view<span style="color: #555555;">.</span><span style="color: #330099;">loadUrl</span><span style="color: #555555;">(</span><span style="color: #cc3300;">"http://www.tutscode.net"</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">private</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MyBrowser</span> <span style="color: #006699;">extends</span> WebViewClient <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">shouldOverrideUrlLoading</span><span style="color: #555555;">(</span>WebView view<span style="color: #555555;">,</span> String url<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
view<span style="color: #555555;">.</span><span style="color: #330099;">loadUrl</span><span style="color: #555555;">(</span>url<span style="color: #555555;">);</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre>
</div>
<br />
Until here, we have finished the process of displaying the website, but when we enter the pages of the website then press the back button, then the application will exit. It should return to the previous page.<br />
<br />
To prevent this, enter the following functions under the <b>MyBrowser</b> function<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">onKeyDown</span><span style="color: #555555;">(</span><span style="color: #007788;">int</span> keyCode<span style="color: #555555;">,</span> KeyEvent event<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #0099ff; font-style: italic;">//when touched by the back button</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">((</span>keyCode <span style="color: #555555;">==</span> KeyEvent<span style="color: #555555;">.</span><span style="color: #330099;">KEYCODE_BACK</span><span style="color: #555555;">)</span> <span style="color: #555555;">&&</span> view<span style="color: #555555;">.</span><span style="color: #330099;">canGoBack</span><span style="color: #555555;">())</span> <span style="color: #555555;">{</span>
view<span style="color: #555555;">.</span><span style="color: #330099;">goBack</span><span style="color: #555555;">();</span> <span style="color: #0099ff; font-style: italic;">//method goback(),to return to the previous page</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">true</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #0099ff; font-style: italic;">// If no page has been opened</span>
<span style="color: #0099ff; font-style: italic;">// it will exit the activity (close the application)</span>
<span style="color: #006699;">return</span> <span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onKeyDown</span><span style="color: #555555;">(</span>keyCode<span style="color: #555555;">,</span> event<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span></span>
</pre>
</div>
<br />
And finally, enter permission to access the internet on <b>AndroidManifest.xml</b><br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;"><uses-permission</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.permission.INTERNET"</span><span style="color: #330099;">/></span></span>
</pre>
</div>
<br />
When it's finished, the program is ready to run<br />
<br />
<br />
<br />
<h3 style="text-align: center;">
<br /></h3>
<div>
<h3 style="text-align: center;">
</h3>
<h3 style="text-align: center;">
</h3>
<h3 style="text-align: center;">
Website Display on Mobile</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-yvaMjXEWTjw/W34l7LR-ZeI/AAAAAAAABLQ/n19AFxTJlOMD6Qiqpfe3GIkkktg68sI7gCLcBGAs/s1600/9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="465" data-original-width="238" src="https://4.bp.blogspot.com/-yvaMjXEWTjw/W34l7LR-ZeI/AAAAAAAABLQ/n19AFxTJlOMD6Qiqpfe3GIkkktg68sI7gCLcBGAs/s1600/9.jpg" /></a></div>
<br />
<br /></div>
Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comtag:blogger.com,1999:blog-3825706424405165268.post-34161008606647615402019-02-03T11:06:00.000+08:002019-02-03T11:06:53.395+08:00Create Card Profile HTML CSS<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-VMQn_0MJ5ZQ/W7CDyhxNC8I/AAAAAAAABXc/8rtLZk6XT3QLENWP8MY8KNptZ-Ozm4O8ACLcBGAs/s1600/CARD%2BPROFILE.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="738" data-original-width="1330" src="https://4.bp.blogspot.com/-VMQn_0MJ5ZQ/W7CDyhxNC8I/AAAAAAAABXc/8rtLZk6XT3QLENWP8MY8KNptZ-Ozm4O8ACLcBGAs/s1600/CARD%2BPROFILE.jpg" /></a></div>
<br />
<hr />
<h2>
Preview</h2>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://drive.google.com/uc?export=download&id=1zSTWXAA46bapC3aY3wv5q_lfP8XCO6qW" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1zSTWXAA46bapC3aY3wv5q_lfP8XCO6qW" width="320" /></a></div>
<br />
<br />
Hello guys, this tutorial, I will create a <b>Card Profile</b> that displays photos, names, short descriptions and social media accounts in the form of animation when the pointer is highlighted (Hover).<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now create a project folder and create the <b>index.html and style.css</b> files in it and include one of your photos in a square. When finished, open index.html and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Card Profile<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"</span>
<span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"card"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"image"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><img</span> <span style="color: #330099;">src=</span><span style="color: #cc3300;">"img.jpg"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"details"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"center"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h1></span>Andi Aspin<span style="color: #330099;"><br><span></span>Web Designer<span style="color: #330099;"></span></h1></span>
<span style="color: #330099;"><p></span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<span style="color: #330099;"></p></span>
<span style="color: #330099;"><ul></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-facebook"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-twitter"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-instagram"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-linkedin"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-google-plus"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></a></li></span>
<span style="color: #330099;"></ul></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
Then, open <b>style.css</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>
{
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#282828</span>;
}
<span style="color: #00aa88;">.card</span>
{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">400px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">400px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#000</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.image</span>{
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.image</span> <span style="color: #330099;">img</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
}
<span style="color: #00aa88;">.card</span><span style="color: #9999ff;">:hover</span> <span style="color: #00aa88;">.image</span> <span style="color: #330099;">img</span>{
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #555555;">.</span><span style="color: #ff6600;">5</span>;
transform<span style="color: #555555;">:</span> translateX(<span style="color: #ff6600;">30</span><span style="color: #555555;">%</span>);
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">70</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">border-top</span><span style="color: #555555;">-</span><span style="color: #006699;">left</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">border-bottom</span><span style="color: #555555;">-</span><span style="color: #006699;">left</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span><span style="color: #ff6600;">#DC143C</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
transform<span style="color: #555555;">-</span>origin<span style="color: #555555;">:</span> <span style="color: #006699;">left</span>;
transform<span style="color: #555555;">:</span> perspective(<span style="color: #ff6600;">2000px</span>) rotateY(<span style="color: #ff6600;">-90</span>deg);
}
<span style="color: #00aa88;">.card</span><span style="color: #9999ff;">:hover</span> <span style="color: #00aa88;">.details</span>{
transform<span style="color: #555555;">:</span> perspective(<span style="color: #ff6600;">2000px</span>) rotateY(<span style="color: #ff6600;">0</span>deg);
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span>{
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translateY(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%</span>);
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">h1</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#DC143C</span>;
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">h1</span> <span style="color: #330099;">span</span>{
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">14px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#262626</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">h1</span> <span style="color: #330099;">p</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#262626</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">ul</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span> <span style="color: #006699;">auto</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> table;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span>{
<span style="color: #006699;">list-style</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">5px</span>;
<span style="color: #006699;">float</span><span style="color: #555555;">:</span> <span style="color: #006699;">left</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">block</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#262626</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
}
<span style="color: #00aa88;">.card</span> <span style="color: #00aa88;">.details</span> <span style="color: #00aa88;">.center</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:hover</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#DC143C</span>;
}</span>
</pre>
</div>
<br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-86525270717491903242019-01-13T11:38:00.000+08:002019-01-13T11:38:18.414+08:00How To Create Installer Visual Studio<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-vNHN9RhC-1E/W2QMTSwG7uI/AAAAAAAABGE/JsNpA0zu5acJJlkkgGLJhlwgYb0ciibtwCLcBGAs/s1600/installer%2Bvb.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="487" data-original-width="960" src="https://2.bp.blogspot.com/-vNHN9RhC-1E/W2QMTSwG7uI/AAAAAAAABGE/JsNpA0zu5acJJlkkgGLJhlwgYb0ciibtwCLcBGAs/s1600/installer%2Bvb.jpg" /></a></div>
<br />
<hr />
<br />
<h2>
Preview</h2>
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://drive.google.com/uc?export=download&id=11p6ZKtuCIA7reVIASU63Ec0B7NAO91PH" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="203" src="https://drive.google.com/uc?export=download&id=11p6ZKtuCIA7reVIASU63Ec0B7NAO91PH" width="320" /></a></div>
<br />
Hello friends, in this post I will explain how to create an installation file (Installer) in the project that we have created using Visual Studio.<br />
<br />
And here, I recommend an application that we will use in creating an installer file called "Setup2Go". Okay, we start, first open Setup2Go, the display will appear as shown below, then select "Create a New Project using the Project Wizard"<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-JwAgyPKrK3c/W2P1uaj38ZI/AAAAAAAABEM/GSqW9xx7YXkC5YdFSIAlzyEM1xhh_L7ZACLcBGAs/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="336" data-original-width="519" src="https://2.bp.blogspot.com/-JwAgyPKrK3c/W2P1uaj38ZI/AAAAAAAABEM/GSqW9xx7YXkC5YdFSIAlzyEM1xhh_L7ZACLcBGAs/s1600/1.png" /></a></div>
<br />
then it will appear a form, and fill it according to your needs. then click "Next"<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-AJy6Y9NxiCY/W2P2I0TMFKI/AAAAAAAABEU/CsnLfmCY8x0yN5L0f8p3-0jlUe5L9G1ngCLcBGAs/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="392" data-original-width="488" src="https://2.bp.blogspot.com/-AJy6Y9NxiCY/W2P2I0TMFKI/AAAAAAAABEU/CsnLfmCY8x0yN5L0f8p3-0jlUe5L9G1ngCLcBGAs/s1600/2.png" /></a></div>
<br />
then find and select the "debug" folder in your project. click "Next", then click "Finish"<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-ZUQZE6JGHTI/W2P2luQI17I/AAAAAAAABEc/yyVDqoTs0BAEgI4e7oXLZX_TftJM_sbAACLcBGAs/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="394" data-original-width="483" src="https://1.bp.blogspot.com/-ZUQZE6JGHTI/W2P2luQI17I/AAAAAAAABEc/yyVDqoTs0BAEgI4e7oXLZX_TftJM_sbAACLcBGAs/s1600/3.png" /></a></div>
<br />
When finished, the display will appear as shown below<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-zLYYG-fOuic/W2P3NBLFuzI/AAAAAAAABEo/9_-pKbySZYUM95Z9MYhk6TCHisSscUeJgCLcBGAs/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="732" data-original-width="1358" src="https://2.bp.blogspot.com/-zLYYG-fOuic/W2P3NBLFuzI/AAAAAAAABEo/9_-pKbySZYUM95Z9MYhk6TCHisSscUeJgCLcBGAs/s1600/4.png" /></a></div>
<br />
On each tab, enter all the completeness you need in your application.<br />
<br />
On the first tab, same as before that contains general information. In the "setup settings" tab and "Requirements" we skip because in general the rules are appropriate. Now we go to the "Files" tab<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
In this tab we will enter the files needed by the application. right click on empty area, then select "Insert File (s)" then select all required files then click "Open".<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-TI8qp7-TgNI/W2P49vo463I/AAAAAAAABE8/CRChlvYzFFoKHwiZDfHPPYjXycwcm3KcQCLcBGAs/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="726" data-original-width="1362" src="https://2.bp.blogspot.com/-TI8qp7-TgNI/W2P49vo463I/AAAAAAAABE8/CRChlvYzFFoKHwiZDfHPPYjXycwcm3KcQCLcBGAs/s1600/5.png" /></a></div>
<br />
After that, we move on the "Shortcut" tab. then right-click the folder "Application Shortcut Folder" and select "New Shortcut"<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-jVmg9xT9rEw/W2P5zhiqIII/AAAAAAAABFM/zGywYzt1aB8v7Y1ZTbandccLJScEzWPKQCLcBGAs/s1600/6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="728" data-original-width="1360" src="https://4.bp.blogspot.com/-jVmg9xT9rEw/W2P5zhiqIII/AAAAAAAABFM/zGywYzt1aB8v7Y1ZTbandccLJScEzWPKQCLcBGAs/s1600/6.png" /></a></div>
<br />
then a form will appear, and select the file with extension (.exe) then click "OK".<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-j1H1C2XtoHU/W2P6TZlt1-I/AAAAAAAABFU/3mbw_WWlKJMpYc0oXzcBndjj8gEQvKfFQCLcBGAs/s1600/7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="445" data-original-width="523" src="https://4.bp.blogspot.com/-j1H1C2XtoHU/W2P6TZlt1-I/AAAAAAAABFU/3mbw_WWlKJMpYc0oXzcBndjj8gEQvKfFQCLcBGAs/s1600/7.png" /></a></div>
<br />
After that, a form will appear again, and complete it according to your needs then click "OK"<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-o__LhKfJOTc/W2P6z5-HUvI/AAAAAAAABFc/I9-lwWTfzgkbGSDqcgmMRw0BAXwJrD4OACLcBGAs/s1600/8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="434" data-original-width="441" src="https://1.bp.blogspot.com/-o__LhKfJOTc/W2P6z5-HUvI/AAAAAAAABFc/I9-lwWTfzgkbGSDqcgmMRw0BAXwJrD4OACLcBGAs/s1600/8.png" /></a></div>
<br />
Up here, we have finished creating shortcuts on the Start Menu. Do the same if you want to add a shortcut on the Desktop and Taskbar (Quick Launch).<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now we go directly to the "setup" tab. in the first part, specify the location / folder setup file that we will create. the second part give the name of the setup file, the third add the icon if you have and finally you can also add the password in your setup file. When done, click "Build" then wait for the process to complete.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-afJF2xvpMXM/W2P8ZoCCtnI/AAAAAAAABFo/HfBMO8dYBPQIAsCgfdCNRHSgERxP3R30wCLcBGAs/s1600/9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="724" data-original-width="1358" src="https://2.bp.blogspot.com/-afJF2xvpMXM/W2P8ZoCCtnI/AAAAAAAABFo/HfBMO8dYBPQIAsCgfdCNRHSgERxP3R30wCLcBGAs/s1600/9.png" /></a></div>
<br />
<br />
<h3>
For more details, please watch the video below</h3>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/GmhYvEgOUao/0.jpg" frameborder="0" height="370" src="https://www.youtube.com/embed/GmhYvEgOUao?feature=player_embedded" width="100%"></iframe></div>
<br />Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-72543611161011188232019-01-05T18:41:00.001+08:002019-01-05T18:41:10.053+08:00How To Create Images Slider In Android<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-pi9UMg4VLg8/W2XBQnV1T2I/AAAAAAAABHo/GUF0xzHqI2MBHIlO91faBtLY1ZhopPGDACLcBGAs/s1600/SLIDER%2BIMG.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="622" data-original-width="960" src="https://3.bp.blogspot.com/-pi9UMg4VLg8/W2XBQnV1T2I/AAAAAAAABHo/GUF0xzHqI2MBHIlO91faBtLY1ZhopPGDACLcBGAs/s1600/SLIDER%2BIMG.jpg" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://drive.google.com/uc?export=download&id=1lScOSg6caA3jgjW-SFBaz_umsiX2vNyI" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="556" data-original-width="320" height="320" src="https://drive.google.com/uc?export=download&id=1lScOSg6caA3jgjW-SFBaz_umsiX2vNyI" width="184" /></a></div>
<br />
Hello everyone, in this post I will discuss about how to create a "<b>Images Slider</b>" program in Android Studio which is accompanied by an indicator. Programs like this are often seen in applications that are global like Instagram. Okay, first open Android Studio and create a new project.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
When finished, we need two layouts (<b>activity_main and slide</b>) and two class (<b>MainActivity and MyAdapter</b>). Before that enter some <b>Dependencies</b> needed as follows<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">dependencies</span> {
compile fileTree(dir<span style="color: #555555;">:</span> <span style="color: #cc3300;">'libs'</span><span style="color: #555555;">,</span> include<span style="color: #555555;">:</span> [<span style="color: #cc3300;">'*.jar'</span>])
testCompile <span style="color: #cc3300;">'junit:junit:4.12'</span>
compile <span style="color: #cc3300;">'com.android.support:appcompat-v7:25.3.1'</span>
compile <span style="color: #cc3300;">'com.android.support:design:25.3.1'</span>
compile <span style="color: #cc3300;">'me.relex:circle'</span>
}</span>
</pre>
</div>
<br />
When finished, prepare several images and save them to the <b>drawable</b> folder on your project.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://4.bp.blogspot.com/-HtE9dHmAu-U/W2W7-OU-9LI/AAAAAAAABHU/RjlBEW1C3qIopbrD1K1M8-Vs8JdT0BH_gCLcBGAs/s1600/12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="241" data-original-width="669" src="https://4.bp.blogspot.com/-HtE9dHmAu-U/W2W7-OU-9LI/AAAAAAAABHU/RjlBEW1C3qIopbrD1K1M8-Vs8JdT0BH_gCLcBGAs/s1600/12.png" /></a></div>
<br />
Now, open <b>slide.xml</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><FrameLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><ImageView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/image"</span>
<span style="color: #330099;">android:adjustViewBounds=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_gravity=</span><span style="color: #cc3300;">"center"</span>
<span style="color: #330099;">android:src=</span><span style="color: #cc3300;">"@drawable/one"</span>
<span style="color: #330099;">android:scaleType=</span><span style="color: #cc3300;">"centerCrop"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"fill_parent"</span> <span style="color: #330099;">/></span>
<span style="color: #330099;"></FrameLayout></span></span>
</pre>
</div>
<br />
Continue to the <b>activity_main.xml</b> layout and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><LinearLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:orientation=</span><span style="color: #cc3300;">"vertical"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><RelativeLayout</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><android.support.v4.view.ViewPager</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/pager"</span>
<span style="color: #330099;">android:layout_alignParentTop=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"fill_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"fill_parent"</span><span style="color: #330099;">/></span>
<span style="color: #330099;"><me.relex.circleindicator.CircleIndicator</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/indicator"</span>
<span style="color: #330099;">android:layout_alignParentBottom=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"48dp"</span><span style="color: #330099;">/></span>
<span style="color: #330099;"></RelativeLayout></span>
<span style="color: #330099;"></LinearLayout></span></span>
</pre>
</div>
<br />
When it's finished, we move to the class section, then open <b>MyAdapter</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.content.Context</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v4.view.PagerAdapter</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.LayoutInflater</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.View</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.view.ViewGroup</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.ImageView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">java.util.ArrayList</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MyAdapter</span> <span style="color: #006699;">extends</span> PagerAdapter <span style="color: #555555;">{</span>
<span style="color: #006699;">private</span> ArrayList<span style="color: #555555;"><</span>Integer<span style="color: #555555;">></span> images<span style="color: #555555;">;</span>
<span style="color: #006699;">private</span> LayoutInflater inflater<span style="color: #555555;">;</span>
<span style="color: #006699;">private</span> Context context<span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #cc00ff;">MyAdapter</span><span style="color: #555555;">(</span>Context context<span style="color: #555555;">,</span> ArrayList<span style="color: #555555;"><</span>Integer<span style="color: #555555;">></span> images<span style="color: #555555;">){</span>
<span style="color: #006699;">this</span><span style="color: #555555;">.</span><span style="color: #330099;">context</span> <span style="color: #555555;">=</span> context<span style="color: #555555;">;</span>
<span style="color: #006699;">this</span><span style="color: #555555;">.</span><span style="color: #330099;">images</span> <span style="color: #555555;">=</span> images<span style="color: #555555;">;</span>
inflater <span style="color: #555555;">=</span> LayoutInflater<span style="color: #555555;">.</span><span style="color: #330099;">from</span><span style="color: #555555;">(</span>context<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">destroyItem</span><span style="color: #555555;">(</span>ViewGroup container<span style="color: #555555;">,</span> <span style="color: #007788;">int</span> position<span style="color: #555555;">,</span> Object object<span style="color: #555555;">){</span>
container<span style="color: #555555;">.</span><span style="color: #330099;">removeView</span><span style="color: #555555;">((</span>View<span style="color: #555555;">)</span>object<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">int</span> <span style="color: #cc00ff;">getCount</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> images<span style="color: #555555;">.</span><span style="color: #330099;">size</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> Object <span style="color: #cc00ff;">instantiateItem</span><span style="color: #555555;">(</span>ViewGroup view<span style="color: #555555;">,</span> <span style="color: #007788;">int</span> position<span style="color: #555555;">){</span>
View myImageLayout <span style="color: #555555;">=</span> inflater<span style="color: #555555;">.</span><span style="color: #330099;">inflate</span><span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">slide</span><span style="color: #555555;">,</span> view<span style="color: #555555;">,</span> <span style="color: #006699;">false</span><span style="color: #555555;">);</span>
ImageView myImage <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>ImageView<span style="color: #555555;">)</span> myImageLayout<span style="color: #555555;">.</span><span style="color: #330099;">findViewById</span><span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">image</span><span style="color: #555555;">);</span>
myImage<span style="color: #555555;">.</span><span style="color: #330099;">setImageResource</span><span style="color: #555555;">(</span>images<span style="color: #555555;">.</span><span style="color: #330099;">get</span><span style="color: #555555;">(</span>position<span style="color: #555555;">));</span>
view<span style="color: #555555;">.</span><span style="color: #330099;">addView</span><span style="color: #555555;">(</span>myImageLayout<span style="color: #555555;">,</span> <span style="color: #ff6600;">0</span><span style="color: #555555;">);</span>
<span style="color: #006699;">return</span> myImageLayout<span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">boolean</span> <span style="color: #cc00ff;">isViewFromObject</span><span style="color: #555555;">(</span>View view<span style="color: #555555;">,</span> Object object<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">return</span> view<span style="color: #555555;">.</span><span style="color: #330099;">equals</span><span style="color: #555555;">(</span>object<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre>
</div>
<br />
And finally open <b>Main_Activity</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Handler</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v4.view.ViewPager</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.support.v7.app.AppCompatActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">java.util.ArrayList</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">java.util.Timer</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">java.util.TimerTask</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">me.relex.circleindicator.CircleIndicator</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MainActivity</span> <span style="color: #006699;">extends</span> AppCompatActivity <span style="color: #555555;">{</span>
<span style="color: #006699;">private</span> <span style="color: #006699;">static</span> ViewPager mPager<span style="color: #555555;">;</span>
<span style="color: #006699;">private</span> <span style="color: #006699;">static</span> <span style="color: #007788;">int</span> currentPage <span style="color: #555555;">=</span> <span style="color: #ff6600;">0</span><span style="color: #555555;">;</span>
<span style="color: #006699;">private</span> <span style="color: #006699;">static</span> <span style="color: #006699;">final</span> Integer<span style="color: #555555;">[]</span> img <span style="color: #555555;">=</span> <span style="color: #555555;">{</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">one</span><span style="color: #555555;">,</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">two</span><span style="color: #555555;">,</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">three</span><span style="color: #555555;">,</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">four</span><span style="color: #555555;">,</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">five</span><span style="color: #555555;">,</span>R<span style="color: #555555;">.</span><span style="color: #330099;">drawable</span><span style="color: #555555;">.</span><span style="color: #330099;">six</span><span style="color: #555555;">};</span>
<span style="color: #006699;">private</span> ArrayList<span style="color: #555555;"><</span>Integer<span style="color: #555555;">></span> ImgArray <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> ArrayList<span style="color: #555555;"><</span>Integer<span style="color: #555555;">>();</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">protected</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">activity_main</span><span style="color: #555555;">);</span>
init<span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #006699;">private</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">init</span> <span style="color: #555555;">(){</span>
<span style="color: #006699;">for</span> <span style="color: #555555;">(</span><span style="color: #007788;">int</span> i<span style="color: #555555;">=</span><span style="color: #ff6600;">0</span><span style="color: #555555;">;</span> i<span style="color: #555555;"><</span>img<span style="color: #555555;">.</span><span style="color: #330099;">length</span><span style="color: #555555;">;</span> i<span style="color: #555555;">++)</span>
ImgArray<span style="color: #555555;">.</span><span style="color: #330099;">add</span><span style="color: #555555;">(</span>img<span style="color: #555555;">[</span>i<span style="color: #555555;">]);</span>
mPager <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>ViewPager<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">pager</span><span style="color: #555555;">);</span>
mPager<span style="color: #555555;">.</span><span style="color: #330099;">setAdapter</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> MyAdapter<span style="color: #555555;">(</span>MainActivity<span style="color: #555555;">.</span><span style="color: #330099;">this</span><span style="color: #555555;">,</span> ImgArray<span style="color: #555555;">));</span>
CircleIndicator indicator <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>CircleIndicator<span style="color: #555555;">)</span>findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">indicator</span><span style="color: #555555;">);</span>
indicator<span style="color: #555555;">.</span><span style="color: #330099;">setViewPager</span><span style="color: #555555;">(</span>mPager<span style="color: #555555;">);</span>
<span style="color: #006699;">final</span> Handler handler <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> Handler<span style="color: #555555;">();</span>
<span style="color: #006699;">final</span> Runnable Update <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> Runnable<span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">run</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">(</span>currentPage <span style="color: #555555;">==</span> img<span style="color: #555555;">.</span><span style="color: #330099;">length</span><span style="color: #555555;">){</span>
currentPage <span style="color: #555555;">=</span> <span style="color: #ff6600;">0</span><span style="color: #555555;">;</span>
<span style="color: #555555;">}</span>
mPager<span style="color: #555555;">.</span><span style="color: #330099;">setCurrentItem</span><span style="color: #555555;">(</span>currentPage<span style="color: #555555;">++,</span> <span style="color: #006699;">true</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">};</span>
<span style="color: #0099ff; font-style: italic;">//Auto start</span>
Timer swipeTimer <span style="color: #555555;">=</span> <span style="color: #006699;">new</span> Timer<span style="color: #555555;">();</span>
swipeTimer<span style="color: #555555;">.</span><span style="color: #330099;">schedule</span><span style="color: #555555;">(</span><span style="color: #006699;">new</span> TimerTask<span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">run</span><span style="color: #555555;">()</span> <span style="color: #555555;">{</span>
handler<span style="color: #555555;">.</span><span style="color: #330099;">post</span><span style="color: #555555;">(</span>Update<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">},</span> <span style="color: #ff6600;">2500</span><span style="color: #555555;">,</span> <span style="color: #ff6600;">2500</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre>
</div>
<br />
If there is no error here, the program is ready to run. <i>You need to know that this program will display images automatically, if you want to make it not automatic, you just delete the code in the Auto start section.</i>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comtag:blogger.com,1999:blog-3825706424405165268.post-61503580495325749602018-11-13T14:02:00.000+08:002018-11-13T14:12:46.170+08:00How To Play Youtube In Android Studio<br />
Hello guys, on this occasion I will show you how to add <b>Youtube Player</b> on Android Studio.<br />
This tutorial is very useful for those of you who have a youtube channel and want to show your videos to other platforms such as applications, <i>web</i> and so on.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
But before that you must have an "API" as shown below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-0VGXyD7Mjkc/W3u01zbeRWI/AAAAAAAABJ0/IwCn_hDRrx4Go6W3o76sngXCf6PUR2teQCLcBGAs/s1600/3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="380" data-original-width="850" src="https://2.bp.blogspot.com/-0VGXyD7Mjkc/W3u01zbeRWI/AAAAAAAABJ0/IwCn_hDRrx4Go6W3o76sngXCf6PUR2teQCLcBGAs/s1600/3.jpg" /></a></div>
<br />
Now, we download the Youtube Player library <a href="https://developers.google.com/youtube/android/player/downloads/" target="_blank"><i>here</i></a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-INF6hmehkWo/W3u16rZeWGI/AAAAAAAABJ8/L2gL7l63YaMIBolrIt3sUA4CTPUdZR_MACLcBGAs/s1600/4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="349" data-original-width="833" src="https://2.bp.blogspot.com/-INF6hmehkWo/W3u16rZeWGI/AAAAAAAABJ8/L2gL7l63YaMIBolrIt3sUA4CTPUdZR_MACLcBGAs/s1600/4.jpg" /></a></div>
<br />
If it's been downloaded, ekstract all files in the <b>app</b> folder in your project<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-0q0No24qBXU/W3u24cViC2I/AAAAAAAABKI/Rkm4ZCLEi30m7m1KT1U4eyVfPKjtf7PqQCLcBGAs/s1600/5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="348" data-original-width="626" src="https://1.bp.blogspot.com/-0q0No24qBXU/W3u24cViC2I/AAAAAAAABKI/Rkm4ZCLEi30m7m1KT1U4eyVfPKjtf7PqQCLcBGAs/s1600/5.jpg" /></a></div>
<br />
in the <b>libs</b> folder, there is a <b>.jar</b> file that we enter into <b>dependencies</b><br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">dependencies</span> {
compile fileTree(dir<span style="color: #555555;">:</span> <span style="color: #cc3300;">'libs'</span><span style="color: #555555;">,</span> include<span style="color: #555555;">:</span> [<span style="color: #cc3300;">'*.jar'</span>])
testCompile <span style="color: #cc3300;">'junit:junit:4.12'</span>
compile <span style="color: #cc3300;">'com.android.support:appcompat-v7:23.4.0'</span>
compile <span style="color: #cc3300;">'com.android.support:design:23.4.0'</span>
compile files(<span style="color: #cc3300;">'libs/YouTubeAndroidPlayerApi.jar'</span>)
}</span>
</pre>
</div>
<br />
When finished, open <b>activity_main.xml</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><?xml version="1.0" encoding="utf-8"?></span>
<span style="color: #330099;"><RelativeLayout</span> <span style="color: #330099;">xmlns:android=</span><span style="color: #cc3300;">"http://schemas.android.com/apk/res/android"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:background=</span><span style="color: #cc3300;">"#000"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"match_parent"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><com.google.android.youtube.player.YouTubePlayerView</span>
<span style="color: #330099;">android:id=</span><span style="color: #cc3300;">"@+id/youtube_player_view"</span>
<span style="color: #330099;">android:layout_centerVertical=</span><span style="color: #cc3300;">"true"</span>
<span style="color: #330099;">android:layout_width=</span><span style="color: #cc3300;">"match_parent"</span>
<span style="color: #330099;">android:layout_height=</span><span style="color: #cc3300;">"wrap_content"</span><span style="color: #330099;">/></span>
<span style="color: #330099;"></RelativeLayout></span></span>
</pre>
</div>
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now, open <b>MainActivity.java</b> then enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #006699;">import</span> <span style="color: #00ccff;">android.os.Bundle</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.Button</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">android.widget.Toast</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">com.google.android.youtube.player.YouTubeBaseActivity</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">com.google.android.youtube.player.YouTubeInitializationResult</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">com.google.android.youtube.player.YouTubePlayer</span><span style="color: #555555;">;</span>
<span style="color: #006699;">import</span> <span style="color: #00ccff;">com.google.android.youtube.player.YouTubePlayerView</span><span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">class</span> <span style="color: #00aa88;">MainActivity</span> <span style="color: #006699;">extends</span> YouTubeBaseActivity <span style="color: #006699;">implements</span> YouTubePlayer<span style="color: #555555;">.</span><span style="color: #330099;">OnInitializedListener</span> <span style="color: #555555;">{</span>
YouTubePlayerView youTubePlayerView<span style="color: #555555;">;</span>
Button btn<span style="color: #555555;">;</span>
<span style="color: #006699;">public</span> <span style="color: #006699;">static</span> <span style="color: #006699;">final</span> String API_KEY <span style="color: #555555;">=</span> <span style="color: #cc3300;">"YOUR-API-KEY"</span><span style="color: #555555;">;</span>
<span style="color: #0099ff; font-style: italic;">//www.youtube.com/watch?v=OTOku-K_ORk</span>
<span style="color: #0099ff; font-style: italic;">//id video "OTOku-K_ORk"</span>
String VIDEO_ID <span style="color: #555555;">=</span> <span style="color: #cc3300;">"YOUR-ID-VIDEO"</span><span style="color: #555555;">;</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">protected</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onCreate</span><span style="color: #555555;">(</span>Bundle savedInstanceState<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">super</span><span style="color: #555555;">.</span><span style="color: #330099;">onCreate</span><span style="color: #555555;">(</span>savedInstanceState<span style="color: #555555;">);</span>
setContentView<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">layout</span><span style="color: #555555;">.</span><span style="color: #330099;">activity_main</span><span style="color: #555555;">);</span>
youTubePlayerView <span style="color: #555555;">=</span> <span style="color: #555555;">(</span>YouTubePlayerView<span style="color: #555555;">)</span> findViewById<span style="color: #555555;">(</span>R<span style="color: #555555;">.</span><span style="color: #330099;">id</span><span style="color: #555555;">.</span><span style="color: #330099;">youtube_player_view</span><span style="color: #555555;">);</span>
youTubePlayerView<span style="color: #555555;">.</span><span style="color: #330099;">initialize</span><span style="color: #555555;">(</span>API_KEY<span style="color: #555555;">,</span><span style="color: #006699;">this</span><span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onInitializationSuccess</span><span style="color: #555555;">(</span>YouTubePlayer<span style="color: #555555;">.</span><span style="color: #330099;">Provider</span> provider<span style="color: #555555;">,</span> YouTubePlayer player<span style="color: #555555;">,</span> <span style="color: #007788;">boolean</span> wasRestored<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
<span style="color: #006699;">if</span><span style="color: #555555;">(</span><span style="color: #006699;">null</span><span style="color: #555555;">==</span> player<span style="color: #555555;">)</span> <span style="color: #006699;">return</span><span style="color: #555555;">;</span>
<span style="color: #0099ff; font-style: italic;">// Start buffering</span>
<span style="color: #006699;">if</span> <span style="color: #555555;">(!</span>wasRestored<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
player<span style="color: #555555;">.</span><span style="color: #330099;">cueVideo</span><span style="color: #555555;">(</span>VIDEO_ID<span style="color: #555555;">);</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span>
<span style="color: #9999ff;">@Override</span>
<span style="color: #006699;">public</span> <span style="color: #007788;">void</span> <span style="color: #cc00ff;">onInitializationFailure</span><span style="color: #555555;">(</span>YouTubePlayer<span style="color: #555555;">.</span><span style="color: #330099;">Provider</span> provider<span style="color: #555555;">,</span> YouTubeInitializationResult youTubeInitializationResult<span style="color: #555555;">)</span> <span style="color: #555555;">{</span>
Toast<span style="color: #555555;">.</span><span style="color: #330099;">makeText</span><span style="color: #555555;">(</span><span style="color: #006699;">this</span><span style="color: #555555;">,</span> <span style="color: #cc3300;">"Failed to initialize."</span><span style="color: #555555;">,</span> Toast<span style="color: #555555;">.</span><span style="color: #330099;">LENGTH_LONG</span><span style="color: #555555;">).</span><span style="color: #330099;">show</span><span style="color: #555555;">();</span>
<span style="color: #555555;">}</span>
<span style="color: #555555;">}</span></span>
</pre>
</div>
<br />
And the last enter the permission in <b>AndroidManifest.xml</b><br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;"><uses-permission</span> <span style="color: #330099;">android:name=</span><span style="color: #cc3300;">"android.permission.INTERNET"</span><span style="color: #330099;">/></span></span>
</pre>
</div>
<br />
When it's finished, run the program and the results are more or less like the picture below<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-iMIsK3GnThY/W3u-jPIo5MI/AAAAAAAABKk/1zCHGvAbZN4Ssal59-IJxGhIibolvAJYwCLcBGAs/s1600/6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="465" data-original-width="238" src="https://1.bp.blogspot.com/-iMIsK3GnThY/W3u-jPIo5MI/AAAAAAAABKk/1zCHGvAbZN4Ssal59-IJxGhIibolvAJYwCLcBGAs/s1600/6.jpg" /></a></div>
<br />Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-9448820900904845832018-11-11T22:26:00.000+08:002018-11-13T10:43:23.885+08:00Accoridon Image Hover JavaScript<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-73kVTPGbCQI/W7GTWmM1h8I/AAAAAAAABZ8/iT756Pg5mvofehDC_75rXSZDxu8_aA5IwCLcBGAs/s1600/ACCORDION%2BIMAGE.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="562" data-original-width="1000" src="https://1.bp.blogspot.com/-73kVTPGbCQI/W7GTWmM1h8I/AAAAAAAABZ8/iT756Pg5mvofehDC_75rXSZDxu8_aA5IwCLcBGAs/s1600/ACCORDION%2BIMAGE.jpg" /></a></div>
<br />
<hr />
<br />
<h2>
Preview</h2>
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://drive.google.com/uc?export=download&id=1EsGkPGIiVAJwVBXgcjPI54kT81OGl52k" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1EsGkPGIiVAJwVBXgcjPI54kT81OGl52k" width="320" /></a></div>
<br />
<br />
Hello guys, this tutorial is about creating an accordion card that has <b>4 parts</b>, and switching when the pointer is highlighted <b>(hover)</b>. You can make this tutorial as a reference for the project you are working on or your college assignment on <i>campus</i>.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now, create a project folder and add the <b>index.html</b> and <b>style.css</b> files in it and add 4 images in <i>landscape</i> mode as background. When finished, open <b>index.html</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Typing<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><script </span><span style="color: #330099;">src=</span><span style="color: #cc3300;">"https://code.jquery.com/jquery-3.2.1.js"</span><span style="color: #330099;">></script></span>
<span style="color: #330099;"><script></span>
$(<span style="color: #336666;">document</span>).ready(<span style="color: #006699;">function</span> (){
$(<span style="color: #cc3300;">'.cardNavbar ul li:nth-child(1)'</span>).on(<span style="color: #cc3300;">'mouseover'</span>,<span style="color: #006699;">function</span>(){
$(<span style="color: #cc3300;">'.cardContainer .cardSingle'</span>).removeClass(<span style="color: #cc3300;">'active'</span>);
$(<span style="color: #cc3300;">'.cardContainer .cardSingle:nth-child(1)'</span>).addClass(<span style="color: #cc3300;">'active'</span>);
})
$(<span style="color: #cc3300;">'.cardNavbar ul li:nth-child(2)'</span>).on(<span style="color: #cc3300;">'mouseover'</span>,<span style="color: #006699;">function</span>(){
$(<span style="color: #cc3300;">'.cardContainer .cardSingle'</span>).removeClass(<span style="color: #cc3300;">'active'</span>);
$(<span style="color: #cc3300;">'.cardContainer .cardSingle:nth-child(2)'</span>).addClass(<span style="color: #cc3300;">'active'</span>);
})
$(<span style="color: #cc3300;">'.cardNavbar ul li:nth-child(3)'</span>).on(<span style="color: #cc3300;">'mouseover'</span>,<span style="color: #006699;">function</span>(){
$(<span style="color: #cc3300;">'.cardContainer .cardSingle'</span>).removeClass(<span style="color: #cc3300;">'active'</span>);
$(<span style="color: #cc3300;">'.cardContainer .cardSingle:nth-child(3)'</span>).addClass(<span style="color: #cc3300;">'active'</span>);
})
$(<span style="color: #cc3300;">'.cardNavbar ul li:nth-child(4)'</span>).on(<span style="color: #cc3300;">'mouseover'</span>,<span style="color: #006699;">function</span>(){
$(<span style="color: #cc3300;">'.cardContainer .cardSingle'</span>).removeClass(<span style="color: #cc3300;">'active'</span>);
$(<span style="color: #cc3300;">'.cardContainer .cardSingle:nth-child(4)'</span>).addClass(<span style="color: #cc3300;">'active'</span>);
})
})
<span style="color: #330099;"></script></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardSlider"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardContainer"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardSingle"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><article></span>
<span style="color: #330099;"><h1></span>Card 1<span style="color: #330099;"></h1></span>
<span style="color: #330099;"><p></span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book.
<span style="color: #330099;"></p></span>
<span style="color: #330099;"></article></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardSingle"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><article></span>
<span style="color: #330099;"><h1></span>Card 2<span style="color: #330099;"></h1></span>
<span style="color: #330099;"><p></span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book.
<span style="color: #330099;"></p></span>
<span style="color: #330099;"></article></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardSingle"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><article></span>
<span style="color: #330099;"><h1></span>Card 3<span style="color: #330099;"></h1></span>
<span style="color: #330099;"><p></span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book.
<span style="color: #330099;"></p></span>
<span style="color: #330099;"></article></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardSingle"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><article></span>
<span style="color: #330099;"><h1></span>Card 4<span style="color: #330099;"></h1></span>
<span style="color: #330099;"><p></span>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book.
<span style="color: #330099;"></p></span>
<span style="color: #330099;"></article></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"cardNavbar"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><ul></span>
<span style="color: #330099;"><li></span>Card One<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>Card Two<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>Card Three<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>Card Four<span style="color: #330099;"></li></span>
<span style="color: #330099;"></ul></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
Now, open <b>style.css</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#222</span>;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> Arial<span style="color: #555555;">,</span> Helvetica<span style="color: #555555;">,</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #006699;">bold</span>;
}
<span style="color: #00aa88;">.cardSlider</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1000px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">400px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
}
<span style="color: #00aa88;">.cardContainer</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">350px</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">dodgerblue</span>;
}
<span style="color: #00aa88;">.cardNavbar</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">relative</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">dodgerblue</span>;
}
<span style="color: #00aa88;">.cardNavbar</span> <span style="color: #330099;">ul</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">white</span>;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> flex;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
}
<span style="color: #00aa88;">.cardNavbar</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span>{
<span style="color: #006699;">list-style</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">25</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">border-right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#262626</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
}
<span style="color: #00aa88;">.cardNavbar</span> <span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:last-child</span>{
<span style="color: #006699;">border-right</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
}
<span style="color: #00aa88;">.cardContainer</span> <span style="color: #00aa88;">.cardSingle</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">350px</span>;
box<span style="color: #555555;">-</span>sizing<span style="color: #555555;">:</span> <span style="color: #006699;">border</span><span style="color: #555555;">-</span>box;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">dodgerblue</span>;
<span style="color: #006699;">background-position</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span> <span style="color: #009999;">!important</span>;
}
<span style="color: #330099;">article</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> rgba(<span style="color: #ff6600;">255</span><span style="color: #555555;">,</span><span style="color: #ff6600;">255</span><span style="color: #555555;">,</span><span style="color: #ff6600;">255</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">5</span>);
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
}
<span style="color: #00aa88;">.cardContainer</span> <span style="color: #00aa88;">.cardSingle</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">1</span><span style="color: #555555;">)</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(img1.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
}
<span style="color: #00aa88;">.cardContainer</span> <span style="color: #00aa88;">.cardSingle</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">2</span><span style="color: #555555;">)</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(img2.jpeg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
}
<span style="color: #00aa88;">.cardContainer</span> <span style="color: #00aa88;">.cardSingle</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">3</span><span style="color: #555555;">)</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(img3.jpeg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
}
<span style="color: #00aa88;">.cardContainer</span> <span style="color: #00aa88;">.cardSingle</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">4</span><span style="color: #555555;">)</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(img4.jpeg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
}
<span style="color: #00aa88;">.active</span>{
<span style="color: #006699;">z-index</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1</span>;
}</span>
</pre>
</div>
<br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-2428154943581677522018-10-23T09:58:00.002+08:002018-10-23T20:18:49.906+08:00Create Simple Pagination HTML CSS<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-LAwCnVVkcRQ/W7CQNEfIJHI/AAAAAAAABYY/mLXi-YbPkLg4LzPRH0hnnj7UkbIGJvvQgCLcBGAs/s1600/PAGINATION.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Create Simple Pagination HTML CSS" border="0" data-original-height="738" data-original-width="1330" src="https://2.bp.blogspot.com/-LAwCnVVkcRQ/W7CQNEfIJHI/AAAAAAAABYY/mLXi-YbPkLg4LzPRH0hnnj7UkbIGJvvQgCLcBGAs/s1600/PAGINATION.jpg" /></a></div>
<br />
<hr />
<br />
<h2>
Preview</h2>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://drive.google.com/uc?export=download&id=1gP1rmvp741jQtqd280FZxoSSrtDbs_Zc" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1gP1rmvp741jQtqd280FZxoSSrtDbs_Zc" width="320" /></a></div>
<br />
<br />
Hello friends, in this tutorial I will make a simple pagination. <b>Pagination</b> is a feature to group pages on a website so it will be <b><i>very easy</i></b> to access certain pages if you have many pages on "your website". There are many types of tutorials like this, but I will review them for you.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Okey, First create a project folder and create the <b>index.html </b>and<b> style.css</b> files in it. When it's finished, open the <b>index.html</b> file and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Pagination<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><ul></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span><span style="background-color: #ffaaaa; color: #aa0000;"><</span><span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"active"</span><span style="color: #330099;">></span>1<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>2<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>3<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>4<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>5<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>><span style="color: #330099;"></a></li></span>
<span style="color: #330099;"></ul></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre>
</div>
<br />
Next, open <b>style.css</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>{
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> Arial<span style="color: #555555;">,</span> Helvetica<span style="color: #555555;">,</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-weight</span><span style="color: #555555;">:</span> <span style="color: #006699;">bold</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">dodgerblue</span>;
}
<span style="color: #330099;">ul</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> flex;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
box<span style="color: #555555;">-</span>shadow<span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">15px</span> <span style="color: #ff6600;">20px</span> rgba(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">5</span>)<span style="color: #555555;">,</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">4px</span> <span style="color: #ff6600;">#1886c5</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">25px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span>{
<span style="color: #006699;">list-style</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">block</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">40px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#262626</span>;
<span style="color: #006699;">text-decoration</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">4px</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">5px</span>;
box<span style="color: #555555;">-</span>shadow<span style="color: #555555;">:</span> <span style="color: #006699;">inset</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">5px</span> <span style="color: #ff6600;">10px</span> rgba(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">1</span>)<span style="color: #555555;">,</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">2px</span> <span style="color: #ff6600;">5px</span> rgba(<span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,</span><span style="color: #ff6600;">0</span><span style="color: #555555;">,.</span><span style="color: #ff6600;">5</span>);
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:first-child</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">20px</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:last-child</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">border</span><span style="color: #555555;">-</span>radius<span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">20px</span> <span style="color: #ff6600;">20px</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #00aa88;">.active</span><span style="color: #555555;">,</span>
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:hover</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #336666;">dodgerblue</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
}</span>
</pre>
</div>
<br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-55292166678743739432018-10-21T11:23:00.000+08:002018-10-21T11:34:28.436+08:00Button Hover Border Effects CSS<div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-hprdA5WBETA/W64hTbvLKgI/AAAAAAAABUI/lICHN_VHwPU7OYDzM5pY_c36bP2e-bwUgCLcBGAs/s1600/button%2Bborder%2Bhover.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Button Hover Border Effects CSS" border="0" data-original-height="324" data-original-width="694" src="https://2.bp.blogspot.com/-hprdA5WBETA/W64hTbvLKgI/AAAAAAAABUI/lICHN_VHwPU7OYDzM5pY_c36bP2e-bwUgCLcBGAs/s1600/button%2Bborder%2Bhover.jpg" /></a></div><br />
<hr /><br />
<h2>Preview</h2><div class="separator" style="clear: both; text-align: left;"><a href="https://drive.google.com/uc?export=download&id=1GPuKwL15ET_Ko9EhN35tCRt3fV5MGMEI" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1GPuKwL15ET_Ko9EhN35tCRt3fV5MGMEI" width="320" /></a></div><br />
<br />
Hello guys, this time I will make a button with "animation" on the border. By making an effect on a button when the pointer is<b> highlighted or when clicked</b>, it will look more vivid and make users more comfortable using it.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
As usual, create a project folder, then create <b>index.html</b> and <b>style.css</b> files.<br />
<br />
Open <b>index.html</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Button Border Animation<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">><span></span></span>Hover Me<span style="color: #330099;"></a></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span>
</span></pre></div><br />
open <b>style.css</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>
{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#222</span>;
}
<span style="color: #330099;">a</span>
{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,</span> <span style="color: #ff6600;">-50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">180px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#222</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">text-decoration</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">20px</span>;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">'Roboto'</span><span style="color: #555555;">,</span> <span style="color: #006699;">sans-serif</span>;
<span style="color: #006699;">letter-spacing</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">4px</span>;
}
<span style="color: #330099;">a</span><span style="color: #9999ff;">:before</span><span style="color: #555555;">,</span>
<span style="color: #330099;">a</span><span style="color: #9999ff;">:after</span><span style="color: #555555;">,</span>
<span style="color: #330099;">span</span><span style="color: #9999ff;">:before</span><span style="color: #555555;">,</span>
<span style="color: #330099;">span</span><span style="color: #9999ff;">:after</span>
{
<span style="color: #006699;">content</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">''</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">10px</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#ff0</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">1s</span>;
<span style="color: #006699;">mix</span><span style="color: #555555;">-</span>blend<span style="color: #555555;">-</span>mode<span style="color: #555555;">:</span> hue;
}
<span style="color: #330099;">a</span><span style="color: #9999ff;">:before</span>
{
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
}
<span style="color: #330099;">a</span><span style="color: #9999ff;">:after</span>
{
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
<span style="color: #006699;">right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
}
<span style="color: #330099;">span</span><span style="color: #9999ff;">:before</span>
{
<span style="color: #006699;">bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
}
<span style="color: #330099;">span</span><span style="color: #9999ff;">:after</span>
{
<span style="color: #006699;">bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
<span style="color: #006699;">right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-2px</span>;
}
<span style="color: #330099;">a</span><span style="color: #9999ff;">:hover:before</span><span style="color: #555555;">,</span>
<span style="color: #330099;">a</span><span style="color: #9999ff;">:hover:after</span><span style="color: #555555;">,</span>
<span style="color: #330099;">a</span><span style="color: #9999ff;">:hover</span> <span style="color: #330099;">span</span><span style="color: #9999ff;">:before</span><span style="color: #555555;">,</span>
<span style="color: #330099;">a</span><span style="color: #9999ff;">:hover</span> <span style="color: #330099;">span</span><span style="color: #9999ff;">:after</span>
{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> calc(<span style="color: #ff6600;">180px</span> <span style="color: #555555;">/</span><span style="color: #ff6600;">2</span>);
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> calc(<span style="color: #ff6600;">50px</span> <span style="color: #555555;">/</span><span style="color: #ff6600;">2</span>);
}</span>
</pre></div><br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-84013819255526043642018-10-04T11:19:00.001+08:002018-10-06T19:51:52.535+08:00Create Parallax Effect HTML CSS<div class="separator" style="clear: both; text-align: center;"><a href="https://3.bp.blogspot.com/-eSf0MVQB1p0/W7F5pmPYiAI/AAAAAAAABYs/BcP6LTd8nlkhyZ_h3F7os0T2WNP3OQA_QCLcBGAs/s1600/PARALLAX.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Create Parallax Effect HTML CSS" border="0" data-original-height="562" data-original-width="1000" src="https://3.bp.blogspot.com/-eSf0MVQB1p0/W7F5pmPYiAI/AAAAAAAABYs/BcP6LTd8nlkhyZ_h3F7os0T2WNP3OQA_QCLcBGAs/s1600/PARALLAX.jpg" /></a></div><br />
<hr /><br />
<h2>Preview</h2><br />
<div class="separator" style="clear: both; text-align: left;"><a href="https://drive.google.com/uc?export=download&id=1-FNXXKK7orEAA3lf5dEhHl7MEvIVkL64" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1-FNXXKK7orEAA3lf5dEhHl7MEvIVkL64" width="320" /></a></div><br />
Hello friends, this time I will make a <i><u>Parallax effect using 4 background pages</u></i>. The Website Design Phenomenon with <b>Parallax</b> Scrolling is increasing in popularity on the Internet in 2015. Visitors enjoy the browsing experience on the new website. "<i>Web developers and designers</i>" are competing to decorate their website to attract visitors in various ways or parallax techniques.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Now, Create a project folder and enter it in the <b>index.html and style.css</b> files, then include <b>4 images</b> in landscape mode. If it's ready, open <b>index.html</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Parallax City<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">id=</span><span style="color: #cc3300;">"box1"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h1></span>WATAMPONE<span style="color: #330099;"></h1></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">id=</span><span style="color: #cc3300;">"box2"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h1></span>NEW YORK<span style="color: #330099;"></h1></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">id=</span><span style="color: #cc3300;">"box3"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h1></span>PARIS<span style="color: #330099;"></h1></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"><div</span> <span style="color: #330099;">id=</span><span style="color: #cc3300;">"box4"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><h1></span>AUSTRALIA<span style="color: #330099;"></h1></span>
<span style="color: #330099;"></div></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre></div><br />
Next, open <b>style.css</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #cc00ff;">#box1</span>{
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span>vh;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">background-image</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(watampone.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> table;
<span style="color: #006699;">background-attachment</span><span style="color: #555555;">:</span> <span style="color: #006699;">fixed</span>;
}
<span style="color: #cc00ff;">#box2</span>{
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span>vh;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">background-image</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(newyork.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> table;
<span style="color: #006699;">background-attachment</span><span style="color: #555555;">:</span> <span style="color: #006699;">fixed</span>;
}
<span style="color: #cc00ff;">#box3</span>{
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span>vh;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">background-image</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(paris.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> table;
<span style="color: #006699;">background-attachment</span><span style="color: #555555;">:</span> <span style="color: #006699;">fixed</span>;
}
<span style="color: #cc00ff;">#box4</span>{
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span>vh;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">background-image</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">url(australia.jpg)</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">-</span><span style="color: #006699;">size</span><span style="color: #555555;">:</span> cover;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> table;
<span style="color: #006699;">background-attachment</span><span style="color: #555555;">:</span> <span style="color: #006699;">fixed</span>;
}
<span style="color: #330099;">h1</span>{
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> arial <span style="color: #336666;">black</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span><span style="color: #336666;">white</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0px</span>;
<span style="color: #006699;">text-shadow</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">2px</span> <span style="color: #ff6600;">2px</span> <span style="color: #ff6600;">#000</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">table-cell</span>;
<span style="color: #006699;">vertical-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">middle</span>;
}</span>
</pre></div><br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-20087104788909529152018-10-01T15:25:00.000+08:002018-10-06T19:53:45.541+08:00Create Sliding Social Media Button HTML CSS<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-FQcmec2Akc0/W7GAJj3BphI/AAAAAAAABZg/TOsVghS0CSUlkwFUye7QOtNaykWMpGUfACLcBGAs/s1600/SLIDING%2BSOCIAL%2BMEDIA%2BBUTTON.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Sliding Social Media Button HTML CSS" border="0" data-original-height="562" data-original-width="1000" src="https://2.bp.blogspot.com/-FQcmec2Akc0/W7GAJj3BphI/AAAAAAAABZg/TOsVghS0CSUlkwFUye7QOtNaykWMpGUfACLcBGAs/s1600/SLIDING%2BSOCIAL%2BMEDIA%2BBUTTON.jpg" /></a></div><br />
<hr /><br />
<h2>Preview</h2><div class="separator" style="clear: both; text-align: left;"><a href="https://drive.google.com/uc?export=download&id=1FxkMxg9EUsrkKzZwGgI94d98KFreHrID" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=1FxkMxg9EUsrkKzZwGgI94d98KFreHrID" width="320" /></a></div><br />
Hello guys, this tutorial is to create a "<b>Sliding Effect</b>" on social media buttons using font awesome. This tutorial is certainly very interesting for those of you who like animation effects. So if you apply it to your website, it will add to the<b> </b>good experience of the users and of course your website will be <b>recommended</b> by other users.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Okey, first create a project folder and enter it in the <b>index.html and style.css</b> files. When finished, open <b>index.html</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Sliding Social Media<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"</span>
<span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><ul></span>
<span style="color: #330099;"><li></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-facebook"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-facebook"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"></a></span>
<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-twitter"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-twitter"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"></a></span>
<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-instagram"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-instagram"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"></a></span>
<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-linkedin"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-linkedin"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"></a></span>
<span style="color: #330099;"></li></span>
<span style="color: #330099;"><li></span>
<span style="color: #330099;"><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-google-plus"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"><i</span> <span style="color: #330099;">class=</span><span style="color: #cc3300;">"fa fa-google-plus"</span> <span style="color: #330099;">aria-hidden=</span><span style="color: #cc3300;">"true"</span><span style="color: #330099;">></i></span>
<span style="color: #330099;"></a></span>
<span style="color: #330099;"></li></span>
<span style="color: #330099;"></ul></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre></div><br />
You can add more buttons, because it's just an example, so I just added <b>4 buttons</b>. Now, open <b>style.css</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #330099;">ul</span>{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> flex;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span>{
<span style="color: #006699;">list-style</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">5px</span>;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">inline</span><span style="color: #555555;">-</span><span style="color: #006699;">block</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">line-height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50px</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">16px</span>;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">inline</span><span style="color: #555555;">-</span><span style="color: #006699;">block</span>;
<span style="color: #006699;">vertical-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">middle</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#f1f1f1</span>;
<span style="color: #006699;">overflow</span><span style="color: #555555;">:</span> <span style="color: #006699;">hidden</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span> <span style="color: #330099;">i</span>{
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">block</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">100</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#777</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover</span> <span style="color: #330099;">a</span> <span style="color: #330099;">i</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">1</span><span style="color: #555555;">)</span>{
transform<span style="color: #555555;">:</span> translateY(<span style="color: #ff6600;">-50px</span>);
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover</span> <span style="color: #330099;">a</span> <span style="color: #330099;">i</span><span style="color: #9999ff;">:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">2</span><span style="color: #555555;">)</span>{
transform<span style="color: #555555;">:</span> translateY(<span style="color: #ff6600;">-50px</span>);
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">1</span><span style="color: #555555;">)</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#3b5998</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">2</span><span style="color: #555555;">)</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#00aced</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">3</span><span style="color: #555555;">)</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#bc2a8d</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">4</span><span style="color: #555555;">)</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#007bb6</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span><span style="color: #9999ff;">:hover:nth-child</span><span style="color: #555555;">(</span><span style="color: #330099;">5</span><span style="color: #555555;">)</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#dd4b39</span>;
}</span>
</pre></div><br />
Save all files and run <b>index.html</b>Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004tag:blogger.com,1999:blog-3825706424405165268.post-76574883235685889592018-09-30T10:53:00.003+08:002018-10-06T19:53:58.360+08:00Menu Hover CSS Effect<div class="separator" style="clear: both; text-align: center;"></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://3.bp.blogspot.com/-GJnF5QsadZo/W64gFp3XrKI/AAAAAAAABT8/n-oKWoLuu-0ghWauniufjFVcPPq4cOcpgCLcBGAs/s1600/MENU%2BHOVER%2BEFFECT.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Menu Hover CSS Effect" border="0" data-original-height="588" data-original-width="1156" src="https://3.bp.blogspot.com/-GJnF5QsadZo/W64gFp3XrKI/AAAAAAAABT8/n-oKWoLuu-0ghWauniufjFVcPPq4cOcpgCLcBGAs/s1600/MENU%2BHOVER%2BEFFECT.jpg" /></a></div><br />
<hr/ ><h2>Preview</h2><div class="separator" style="clear: both; text-align: left;"><a href="https://drive.google.com/uc?export=download&id=15osTRxMafDiV1TiyXr80lzk3mDyV_CRV" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="640" height="240" src="https://drive.google.com/uc?export=download&id=15osTRxMafDiV1TiyXr80lzk3mDyV_CRV" width="320" /></a></div><br />
<br />
Hello guys, this post I will share about how to create a Menu with Effect when highlighting a pointer <b>(Hover)</b>. There are many types of effects we get for using<b> CSS</b> and that is one reference for making your website. Because, the more unique the animation or effect you make, it will make the user experience much better.<br />
<br />
<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><br />
<ins class="adsbygoogle" data-ad-client="ca-pub-5403872783527179" data-ad-format="fluid" data-ad-layout="in-article" data-ad-slot="5145120283" style="display: block; text-align: center;"></ins><br />
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><br />
<br />
Okay, create a project folder and create the<b> index.html </b>and<b> style.css</b> files in it. If it's finished, open <b>index.html</b> and enter the following code<br />
<br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #009999;"><!DOCTYPE html></span>
<span style="color: #330099;"><html</span> <span style="color: #330099;">lang=</span><span style="color: #cc3300;">"en"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><head></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">charset=</span><span style="color: #cc3300;">"UTF-8"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">name=</span><span style="color: #cc3300;">"viewport"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"width=device-width, initial-scale=1.0"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><meta</span> <span style="color: #330099;">http-equiv=</span><span style="color: #cc3300;">"X-UA-Compatible"</span> <span style="color: #330099;">content=</span><span style="color: #cc3300;">"ie=edge"</span><span style="color: #330099;">></span>
<span style="color: #330099;"><title></span>Menu Hover Effect<span style="color: #330099;"></title></span>
<span style="color: #330099;"><link</span> <span style="color: #330099;">rel=</span><span style="color: #cc3300;">"stylesheet"</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"style.css"</span><span style="color: #330099;">></span>
<span style="color: #330099;"></head></span>
<span style="color: #330099;"><body></span>
<span style="color: #330099;"><ul></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>Home<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>About<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>Services<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>Portofolio<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"><li><a</span> <span style="color: #330099;">href=</span><span style="color: #cc3300;">"#"</span><span style="color: #330099;">></span>Contact<span style="color: #330099;"></a></li></span>
<span style="color: #330099;"></ul></span>
<span style="color: #330099;"></body></span>
<span style="color: #330099;"></html></span></span>
</pre></div><br />
The above code only adds 5 menus, and of course you can add more menus to your project.<br />
Now, Open <b>style.css</b> and enter the following code<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f0f3f3; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="color: #330099;">body</span>
{
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">font-family</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">'Roboto'</span><span style="color: #555555;">,</span><span style="color: #006699;">sans-serif</span>;
}
<span style="color: #330099;">ul</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>;
transform<span style="color: #555555;">:</span> translate(<span style="color: #ff6600;">-50</span><span style="color: #555555;">%,-</span><span style="color: #ff6600;">50</span><span style="color: #555555;">%</span>);
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> flex;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span>{
<span style="color: #006699;">list-style</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span>{
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">relative</span>;
<span style="color: #006699;">display</span><span style="color: #555555;">:</span> <span style="color: #006699;">block</span>;
<span style="color: #006699;">text-align</span><span style="color: #555555;">:</span> <span style="color: #006699;">center</span>;
<span style="color: #006699;">margin</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">25px</span>;
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#222</span>;
<span style="color: #006699;">font-size</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">30px</span>;
<span style="color: #006699;">text-decoration</span><span style="color: #555555;">:</span> <span style="color: #006699;">none</span>;
<span style="color: #006699;">text-transform</span><span style="color: #555555;">:</span> <span style="color: #006699;">uppercase</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
<span style="color: #006699;">padding</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">5px</span> <span style="color: #ff6600;">10px</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:before</span>{
<span style="color: #006699;">content</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">''</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">3px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#0a71d2</span>;
<span style="color: #006699;">border-width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">3px</span> <span style="color: #ff6600;">3px</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:hover:before</span>{
<span style="color: #006699;">bottom</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-8px</span>;
<span style="color: #006699;">left</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-8px</span>;
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:after</span>{
<span style="color: #006699;">content</span><span style="color: #555555;">:</span> <span style="color: #cc3300;">''</span>;
<span style="color: #006699;">position</span><span style="color: #555555;">:</span> <span style="color: #006699;">absolute</span>;
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">right</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">height</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">12px</span>;
<span style="color: #006699;">border</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">3px</span> <span style="color: #006699;">solid</span> <span style="color: #ff6600;">#0a71d2</span>;
<span style="color: #006699;">border-width</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">3px</span> <span style="color: #ff6600;">3px</span> <span style="color: #ff6600;">0</span> <span style="color: #ff6600;">0</span>;
transition<span style="color: #555555;">:</span> <span style="color: #ff6600;">.5s</span>;
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">0</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:hover:after</span>{
<span style="color: #006699;">top</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">-8px</span>;
<span style="color: #006699;">right</span><span style="color: #555555;">:-</span><span style="color: #ff6600;">8px</span>;
<span style="color: #006699;">opacity</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">1</span>;
}
<span style="color: #330099;">ul</span> <span style="color: #330099;">li</span> <span style="color: #330099;">a</span><span style="color: #9999ff;">:hover</span>{
<span style="color: #006699;">color</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#fff</span>;
<span style="color: #006699;">background</span><span style="color: #555555;">:</span> <span style="color: #ff6600;">#0a71d2</span>;
}</span>
</pre></div><br />
You can adjust your font type, font color or font size yourself. When finished, save all files and run <b>index.html</b><br />
<br />
Andi Asvin Mahersatillah Suradihttp://www.blogger.com/profile/01691193023285190472noreply@blogger.comIndia20.593684 78.962880000000041-8.6041045000000018 37.654286000000042 49.7914725 120.27147400000004