Wednesday, August 16, 2017

FREE eBook - Learning Python

FREE LEARNING PYTHON EBOOK

Discover the ins and outs of one of the most popular programming languages in the world today with the help of this eBook. Python is a dynamic and diverse language and can be used in everything from web applications to crunching raw data. No matter what you use it for though, we all have to start at the beginning; and Learning Python is your gateway to the world of professional Python development!

This book goes deeper than simply showing you how to build a Python app, giving you the fundamentals of Python programming that every developer needs to know to make the most of the language. Packed with tutorials and examples this title features everything from data structures, writing reusable code, testing, paradigms, and how Python can be adapted. This free eBook will help transform you from a complete beginner to someone ready to bring the best out of their projects.

So get this title now and see just why Python is so beloved today!

Download link: https://www.packtpub.com/packt/free-ebook/learning-python/




Wednesday, July 19, 2017

ExoPlayer: Flexible Media Playback for Android (Google I/O '17)


ExoPlayer is an open source media playback library for Android. Used by thousands of applications, it enables great media experiences and can be customized to suit individual needs. Recent additions to the library have ranged from a new high level API to advanced features such as multi-period DASH support and spatial audio. In this talk you’ll learn what’s new in ExoPlayer, as well as some of ExoPlayer’s key concepts, points of customization and inner workings.


Related Link:
> Android Developers > API Guides > Media and Camera > ExoPlayer


Tuesday, July 18, 2017

EditText with drawable icon


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidedittextchanged.MainActivity">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:mipmap/sym_def_app_icon"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>
<EditText
android:id="@+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="normal EditText"/>
<EditText
android:id="@+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with drawableLeft"
android:drawableLeft="@mipmap/ic_launcher"/>
<EditText
android:id="@+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with drawableRight"
android:drawableRight="@mipmap/ic_launcher_round"/>
<EditText
android:id="@+id/edittext4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with drawableTop"
android:drawableTop="@mipmap/ic_launcher"/>
<EditText
android:id="@+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with drawableBottom"
android:drawableBottom="@mipmap/ic_launcher_round"/>
<EditText
android:id="@+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with background"
android:background="@mipmap/ic_launcher"/>
</LinearLayout>
</FrameLayout>


</LinearLayout>


Monday, July 17, 2017

Set background and alpha of EditText

Examples of Setting background and alpha of EditText:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidedittextchanged.MainActivity">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@android:mipmap/sym_def_app_icon"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>
<EditText
android:id="@+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="28dp"
android:text="normal EditText"/>
<EditText
android:id="@+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with background #50FFFFFF"
android:textSize="28dp"
android:background="#50FFFFFF"/>
<EditText
android:id="@+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with background #FFFFFF"
android:textSize="28dp"
android:background="#FFFFFF"/>
<EditText
android:id="@+id/edittext4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="EditText with background #FFFFFF and alpha=0.5"
android:textSize="28dp"
android:background="#FFFFFF"
android:alpha="0.5"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>

Sunday, July 16, 2017

EditText with custom shape (drawable)


To create EditText with our own shape, create a drawable XML to define our custom shape:

res/drawable/myshape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="10dp">
<solid android:color="#505050"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>


Reference my shape in layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidedittextchanged.MainActivity">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

<EditText
android:id="@+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="normal EditText"/>
<EditText
android:id="@+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="EditText with custom shape"
android:textColorHint="#B0B0B0"
android:textColor="#F0F0F0"
android:background="@drawable/myshape" />

</LinearLayout>


Saturday, July 15, 2017

Download your FREE copy of 'Android Security Cookbook'

Ensure your apps are as tight as can be from outside threats with this cookbook. With recipes you can take to newer versions when needed this 350 page download shows you how to catch the trickiest vulnerabilities before they become a problem and gives you, and your customers, the peace of mind you deserve.

Download your FREE copy of 'Android Security Cookbook'


Thursday, July 13, 2017

AutoCompleteTextView, subclass of EditText with Auto-complete function

AutoCompleteTextView is a subclass of EditText that shows completion suggestions automatically while the user is typing.


To implement AutoCompleteTextView in your app:

Add the AutoCompleteTextView to your layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidedittextchanged.MainActivity">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

<AutoCompleteTextView
android:id="@+id/autocompletetextview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />


</LinearLayout>



Edit res/values/strings.xml to add array that contains all text suggestions.
<resources>
<string name="app_name">AndroidEditTextChanged</string>
<string-array name="suggestion">
<item>January</item>
<item>February</item>
<item>March</item>
<item>April</item>
<item>May</item>
<item>June</item>
<item>July</item>
<item>August</item>
<item>September</item>
<item>October</item>
<item>November</item>
<item>December</item>
</string-array>

</resources>


Set adapter using the string array for the AutoCompleteTextView
package com.blogspot.android_er.androidedittextchanged;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class MainActivity extends AppCompatActivity {

AutoCompleteTextView autoCompleteTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
autoCompleteTextView =
(AutoCompleteTextView)findViewById(R.id.autocompletetextview);

String[] suggestion = getResources().getStringArray(R.array.suggestion);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, suggestion);
autoCompleteTextView.setAdapter(adapter);


}

}