Android
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts
Thursday, September 22, 2016
Friday, March 18, 2016
Greenify save battery life
http://gs5.wonderhowto.com/how-to/automatically-hibernate-apps-for-better-battery-life-no-root-required-0157251/
Monday, September 14, 2015
Notepad
http://www.technipages.com/add-reminder-notes-to-android-home-screen
Friday, January 16, 2015
Android course
https://www.coursera.org/specialization/mobilecloudcomputing2/36?utm_medium=courseDescripTop
Saturday, September 13, 2014
use visual studio for android development
http://stackoverflow.com/questions/1371939/how-can-i-use-ms-visual-studio-for-android-development
Saturday, June 21, 2014
Saturday, June 14, 2014
Friday, June 13, 2014
Android Add viewserver
download ViewServer.java from below
click on Raw and copy whole thing
add java to project, fix the package
add internet permission to project
add ViewServer in activity
In sample project get the 3 code section below
Wednesday, June 4, 2014
FragmentManager and Backstack
#18 Android FragmentManager and Backstack Part 1
https://www.youtube.com/watch?v=ZbKKxYUOH-ccall popBackStack()
call popBackStack("A") go directly to A
call popBackStack ("screen 2", POP_BACK_STACK_INCLUSIVE) remove screen 2 also
OnBackStackChangedListener
getBackStackEntryCount()
getBackStackEntryAt(int index)
BackStackEntry getName() to retrieve the name when addToBackStack (with name) was called.
#19 Android FragmentManager and Backstack Part 2
https://www.youtube.com/watch?v=PqpppvGiCAkTuesday, June 3, 2014
Create Android list fragment step by step according to slidenerd video
other examples
I think slidenerd video is the best, and there are other references below:
Watch video => here (below is step by step of the video, if you watch video it is too quick, you need screen shots to use afterwards)
Create a project
add string-array as the data
create Java
package com.gregchu.f1.app.dummy;
/**
* Created by greg on 6/4/2014.
*/
public class MyListFragment extends ListFragment{{
}
create layout
add listview to layout just created above
add a text view (skipped picture)
then change the listview XML to android:id/list
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/list" />
</LinearLayout>
Change text view
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" />
Add onActivity created
public class MyListFragment extends ListFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.my_list_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
}
Create Adaptor to use data from string-array
public class MyListFragment extends ListFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.my_list_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter= ArrayAdapter.createFromResource(getActivity(),R.array.chu,android.R.layout.simple_list_item_1);
}
}
Add setListAdapter
public class MyListFragment extends ListFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.my_list_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter= ArrayAdapter.createFromResource(getActivity(),R.array.chu,android.R.layout.simple_list_item_1);
setListAdapter(adapter);
}
}
Add item click listener
/*** Created by greg on 6/4/2014.
*/
public class MyListFragment extends ListFragment implements AdapterView.OnItemClickListener{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.my_list_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter= ArrayAdapter.createFromResource(getActivity(),R.array.chu,android.R.layout.simple_list_item_1);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long id) {
Toast.makeText(getActivity(),"Item "+i,Toast.LENGTH_SHORT).show();
}
}
You can run on your device now.
It took me more than 2 hours to create this step by step instruction according the video.
Subscribe to:
Posts (Atom)