Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
MainActivity::
onCreate()
Tablet
ListFragment::
onClick()
MainActivity::
showDetail()
public boolean isDualPane()
{
FragmentManager fragmentManager =
Fragment detailFragment = fragmentManager.findFragmentById( R.id.detail_fragment );
return detailFragment != null && detailFragment.getVisibility() == View.VISIBLE;
}
Yes
MainActivity::
update()
DetailFragment::
onClick()
Phone
No
MainActivity::
startDetail()
DetailActivity::
onCreate()
DetailFragment::
onClick()
-public void onCreate( Bundle bundle )
+public View onCreateView( LayoutInflater inflater,
+ ViewGroup container,
+ Bundle savedInstanceState )
{
- super.onCreate( bundle );
+ super.onCreateView( inflater, container, savedInstanceState );
-setContentView( R.layout.welcome );
+View layout = inflater.inflate( R.layout.welcome, container, false );
Corey Leigh Latislaw
You?
Training
Life cycle
https://github.com/xxv/android-lifecycle
Transition
Record
2.isInLayout()
Replace
Combine
Reuse
Fragment1
Flexible
droiddog.com/android-blog/2011/03/2011-the-year-of-fierce-competition/honeycomb-bee-550x550-e1296765261166/
Why not?
http://developer.android.com/reference/android/support/v4/app/package-summary.html
v4 supports API 4+ (Donut, 1.6+)
v13 support API 13+ (Honeycomb, 3.2+)
Framework only API 11+ (Honeycomb, 3.0+)
http://developer.android.com/reference/android/support/v13/app/package-summary.html
Fragment2
Honeycomb
3.0
API 11
Schedule
HIGH Risk
Refactor
Source: http://www.idc.com/getdoc.jsp?containerId=prUS24857114
http://thenextweb.com/google/2014/06/25/google-activations-io-2014/
Code!
Lead or follow?
Why?
setContentView(R.layout.main);
Opportunity
mint.com/how-it-works/anywhere/android-tablet/
<fragment
android:name="com.example.WelcomeFragment"/>
inflater.inflate(R.layout.welcome, container, false);
Leadership
f6
f1
<TextView/>
Start
Update
Activity
New
Activity
Update
Start
Back
Start
f6
Get XML
Form factor?
...
<fragment
android:id="@+id/welcome"
android:name="com.example.WelcomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
ListFragment
ListFragment
DetailFragment
DetailFragment
{
Activity
FragmentActivity
Note: Default detail view
...
<fragment
android:id="@+id/welcome"
android:name="com.example.WelcomeFragment"
android:layout_width="300dp"
android:layout_height="match_parent" />
public class WelcomeActivity extends
{
@Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}
public void showDetail()
{
if (isDualPane())
{ ... }
}
public boolean isDualPane()
{
// determine and return
}
}
{
<fragment
android:id="@+id/hello"
android:name="com.example.HelloFragment"
android:layout_width="600dp"
android:layout_height="match_parent" />
...
public class WelcomeFragment extends
{
...
@Override
public View onCreateView (LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
{
View layout = inflater.inflate(R.layout.fragment_welcome, container, false);
TextView welcomeText = (TextView) layout.findViewById(R.id.welcome_text);
return layout;
}
...
}
public showDetail() {
// Update current view
if (isDualPane())
{
update();
}
// Start new activity
else
{
startDetailActivity();
}
}
Start from scratch
Dual pane?
{
getFragmentManager();
getSupportFragmentManager();
...
<TextView
android:id="@+id/welcome_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world_string" />
...
New APIs
Full renovation
Best Practices
Start from here
http://thenextweb.com/google/2014/06/25/google-activations-io-2014/
Tablets won't catch on
-import android.app.Activity;
+import android.support.v4.app.FragmentActivity;
-public class MyActivity extends Activity {
+public class MyActivity extends FragmentActivity {
Technical debt
...
public class WelcomeFragment extends Fragment {
// Activity's code
}
sevaeunplugged.wordpress.com/2011/09/13/ostrich-therapy
- welcomeText = (TextView) findViewById( R.id.welcome_text );
+ welcomeText = (TextView) layout.findViewById( R.id.welcome_text );
public class WelcomeActivity extends FragmentActivity
{
@Override
protected void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}
}
...
<fragment
android:id="@+id/welcome"
android:name="com.example.WelcomeFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
<3
Low Risk
stackoverflow.com/questions/5695408/so-what-are-the-exact-advantages-of-fragments-in-android-3-0
Must have a host
Fragment
Pre-Honeycomb
f3
Repeat
A
form factors
Back
f5
play.google.com/store/apps/details?id=com.xfinity.tv
androidpolice.com/tags/comcast
Update
Sunesys
7 Minute Workout
Forxiga
f2
f2
WXPN Radio
Philly ETE
Music Choice
HowAboutWe
Home Sweet Home