Interface for accessing and modifying preference data returned by getSharedPreferences(String, int) . For any particular set of preferences, there is a single instance of this class that all clients share. Modifications to the preferences must go through an SharedPreferences.Editor object to ensure the preference values remain in a consistent state and control when they are committed to storage. Objects that are returned from the various get methods must be treated as immutable by the application. MainActivity.java import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity { EditText user, pass; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
Posts
ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list. For an introduction to how you can dynamically insert views using an adapter, read Building Layouts with an Adapter . list.xml < RelativeLayout 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 :paddingLeft= "@dimen/activity_horizontal_margin" android :paddingRight= "@dimen/activity_horizontal_margin" android :paddingTop= "@dimen/activity_vertical_margin" android :paddingBottom= "@dimen/activity_vertical
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. MainActivity.xml <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <Button android:id="@+id/button" android:layout_width="wrap_content" androi
A splash screen is a graphical control element consisting of window containing an image, a logo and the current version of the software. A splash screen usually appears while a game or program is launching. import android.os.Bundle; import android.os.Handler; import android.app.Activity; import android.content.Intent; import android.view.Menu; public class MainSplashScreen extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.main_splash_screen); // METHOD 1 /****** Create Thread that will sleep for 5 seconds *************/ Thread background = new Thread() { public void run() { try { // Thread will sleep for 5 seconds sleep( 5 * 1000 );