Monday, 2 July 2012

Life cycle of MasterDetailFlow HelloWorld

In my previous post Life cycle of Fragment experience to know Lifecycle of simple Fragment. After that, Google released Android SDK Android SDK Tools Revision 20 support template. You can create HelloWorld running in Fragment easily, using MasterDetailFlow template. It's a great tutorial for Fragment. As a beginner, I suggest all beginner try it and understand it.

It's modified to display lifecycle using the same technique.

Life cycle of MasterDetailFlow HelloWorld


- Create a HelloWorld of MasterDetailFlow, with Minimum Required SDK of API 11 Android 3.0 (Honeycomb) and Build SDK of Android 4.1 (API 16).

- Modify activity_item_twopane.xml to add a TextView to display the status. It's the layout on tablet.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="middle"
tools:context=".ItemListActivity">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical"
>
<fragment android:name="com.example.helloworld.ItemListFragment"
android:id="@+id/item_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="status"/>

</ScrollView>
</LinearLayout>

<FrameLayout android:id="@+id/item_detail_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />

</LinearLayout>


- Modify ItemListActivity.java to implement updateMyStatus() and updateStatus() methods, and display lifecycle.
package com.example.helloworld;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.widget.TextView;

public class ItemListActivity extends FragmentActivity
implements ItemListFragment.Callbacks {

private boolean mTwoPane;

String myStatus = "";
TextView status;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);

if (findViewById(R.id.item_detail_container) != null) {
mTwoPane = true;
((ItemListFragment) getSupportFragmentManager()
.findFragmentById(R.id.item_list))
.setActivateOnItemClick(true);
}

status = (TextView)findViewById(R.id.status);
updateMyStatus("onCreate() with mTwoPane = " + String.valueOf(mTwoPane));
}

private void updateMyStatus(String myst){
updateStatus("ItemListActivity: " + myst);
}

public void updateStatus(String st){
if(status == null){
myStatus += "delay - " + st + "\n";
}else{
myStatus += st + "\n";
status.setText(myStatus);
}
}

@Override
public void onItemSelected(String id) {
if (mTwoPane) {
Bundle arguments = new Bundle();
arguments.putString(ItemDetailFragment.ARG_ITEM_ID, id);
ItemDetailFragment fragment = new ItemDetailFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
.replace(R.id.item_detail_container, fragment)
.commit();

} else {
Intent detailIntent = new Intent(this, ItemDetailActivity.class);
detailIntent.putExtra(ItemDetailFragment.ARG_ITEM_ID, id);
startActivity(detailIntent);
}

updateMyStatus("onItemSelected()");
}

@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
updateMyStatus("onDestroy()");
}

@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
updateMyStatus("onPause()");
}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
updateMyStatus("onResume()");
}

@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
updateMyStatus("onStart()");
}

@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
updateMyStatus("onStop()");
}

}


- Modify ItemDetailFragment.java
package com.example.helloworld;

import com.example.helloworld.dummy.DummyContent;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ItemDetailFragment extends Fragment {

public static final String ARG_ITEM_ID = "item_id";

DummyContent.DummyItem mItem;

public ItemDetailFragment() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments().containsKey(ARG_ITEM_ID)) {
mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
}

updateMyStatus("onCreate()");
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);
if (mItem != null) {
((TextView) rootView.findViewById(R.id.item_detail)).setText(mItem.content);
}

updateMyStatus("onCreateView()");

return rootView;
}

private void updateMyStatus(String myst){
if(getActivity().getClass() == ItemListActivity.class){

String me;

if(mItem == null){
me = "unknown";
}else{
me = mItem.content;
}

((ItemListActivity)getActivity()).updateStatus(" >> ItemDetailFragment: "
+ me + " >> "
+ myst);
}
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
updateMyStatus("onActivityCreated()");
}

@Override
public void onAttach(Activity activity) {
// TODO Auto-generated method stub
super.onAttach(activity);
updateMyStatus("onAttach()");
}

@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
updateMyStatus("onDestroy()");
}

@Override
public void onDestroyView() {
// TODO Auto-generated method stub
super.onDestroyView();
updateMyStatus("onDestroyView()");
}

@Override
public void onDetach() {
// TODO Auto-generated method stub
super.onDetach();
updateMyStatus("onDetach()");
}

@Override
public void onPause() {
// TODO Auto-generated method stub
super.onPause();
updateMyStatus("onPause()");
}

@Override
public void onResume() {
// TODO Auto-generated method stub
super.onResume();
updateMyStatus("onResume()");
}

@Override
public void onStart() {
// TODO Auto-generated method stub
super.onStart();
updateMyStatus("onStart()");
}

@Override
public void onStop() {
// TODO Auto-generated method stub
super.onStop();
updateMyStatus("onStop()");
}

}


Please note that this exercise is applied on tablet version only.

Download the files.

Sunday, 1 July 2012

Apple Laptops Reviews For Apple MacBook Pro MD101LL/A NEWEST VERSION

Apple Laptops Reviews For Apple MacBook Pro MD101LL/A NEWEST VERSION This is the latest version of the laptop that has been issued by the company Apple. Here are some technical details that are owned by an Apple MacBook Pro MD101LL/A 13.3-Inch. The following is some information regarding on Apple Laptops Reviews newest version


Apple Laptops Reviews

Apple Laptops Reviews

Specifications for Apple MacBook Pro MD101LL/A Newest Version

Apple Laptops Reviews
For details as follows:BK99FUW2BRRZ
for prices and more information can be viewed in here.

Acer Laptop Reviews Acer Aspire AS5750Z-4835 15.6-Inch


Acer Laptop Reviews for Acer Aspire AS5750Z-4835 - Below is a review of the laptop acer


acer laptop reviews




This is the acer laptop reviews for Acer Aspire AS5750Z-4835 15.6-Inch which has several features. include the following:

this is some features in general:
The first => it has a 2GHz Intel Pentium Processor B940
The second => 4 GB SDRAM capacity laptop
The third => 500 GB 5400 RPM Hard Drive
The fourth => 15.6-inch
The fifth =>
4.5hours Battery Life and Windows 7 Home Premium 64-bit.
The main features, prices, and further details can be found in here

BK99FUW2BRRZ
thank you for your visit to this blog. 

Google Chrome and Drive for iOS

Google LogoAt Google IO this week, Google announced Chrome and Drive for iOS. This is a pretty big deal in my opinion, but there wasn't that must coverage. So I have dug up some links if you are interested.

Chrome on iOS

Why put Chrome on iOS? Well the short answer is money. Google make a lot of money from the Chrome browser as it doesn't have to pay to feature its search engine on the browser. In addition, Chrome uses the same HTML rendering engine, Webkit, that Safari does. So in the end, like all the other iOS browsers, Google is just re-skinning the UI.



So how did they do? Good but not great. They have come up with a very clean Chrome like UI. For me, the most annoying thing is no quick access to bookmarks. The iOS Chrome has an options button like the wrench you have on your desktop versions. So to get to your Bookmarks, you must click Options -> BookMarks -> Your Bookmark. That's 3 clicks every time you want a bookmark!!!! Annoying. Now the new Tab feature does show most commonly used pages so as you use your browser, that should be a good way to get to your favorite sites. But come on Google, three clicks? Give me a bookmark button somewhere and a bookmark bar. It is not gonna take up that much real estate.



Google Drive

Sounds like from the review, this app is pretty much read only. But really, at this point is that at all surprising? App integration will take a while and right now, you just don't create that much stuff on an iPad anyway. Read only should be fine.

Android 4.1 Jelly Bean on HTC One X



#BoycottApple

BoycottApple

BoycottApple

BoycottApple

BoycottApple

BoycottApple

BoycottApple



Error: The method onItemSelected(String) of type ItemListActivity must override a superclass method

It MAY BE happen if you new a project using the new Android SDK Revision 20: Eclipse complain with errors of:
- The method onItemSelected(String) of type ItemListActivity must override a superclass method
- The method onItemSelected(String) of type new ItemListFragment.Callbacks(){} must override a superclass method



Checking the updated System requirements of Android SDK, only JDK 6 is officially supported:



To fix it: correct Compiler compliance level to 1.6.

- Right click your project, select Properties.


-  Select Java Compiler tab, change Compiler compliance level to 1.6.


- Alternatively, you  can click Window -> Preferences, then select Java -> Compiler to change Compiler compliance level to 1.6 for the whole workspace.


Then clean and re-build. Now fixed with 0 errors.