more android uis

13
More UI of Android

Upload: dennis-jung

Post on 17-Aug-2015

22 views

Category:

Software


0 download

TRANSCRIPT

More UI of Android

Try this on~

List● To show items in vertical

scrolling list● Use ListView component● Item format can be

customized, and most of apps are doing this way.

ListView● Add ListView component● Default list only contains string● Item format can be customized,

and most of apps are doing this way.

ArrayAdapter● Set list items threw ArrayAdapter.● android.R.layout.simple_list_item_1 -> Default list format provided by Android

ListView● setOnItemClickListener -> Set onItemClickListener for list items● ...ClickListener -> Usually used to get response after click certain item

Fragment● Piece of an application's user interface that can be placed in an Activity.● Single Acvitity contains single/multiple fragment, and each of it can be used

like Activity● Used for dynamic & multi-pane UI

Start Fragment● onCreateView -> Creating view layout of fragment● inflate.inflate? -> Create View instance with defined resource

o In this case, set View with R.layout.fragment_main resource file

Start Fragment● FragmentManager -> Interface for interacting with Fragment

● FragmentTransaction -> Add a fragment to the activity state

o In code above, use FragmentTransaction.replace to input layout to target fragment

Start Fragment● Try this~

● Refer: http://examples.javacodegeeks.com/android/core/app/fragment/android-fragments-example/

DrawerLayout● Container for window content that allows for interactive "drawer" views to be

pulled out from the edge of the window.

DrawerLayout● FrameLayout: Layout for

setting main view

● ListView: List which will be setting on drawer

● DrawerLayout is included on Android v4 Support Library package

● For more, look on http://developer.android.com/tools/support-library/features.html#v4

DrawerLayout - onCreate● Set default fragment on onCreate

● DrawerLayout.setDrawerListener: Set event action on drawer

● Change fragment when list item on list view has been clicked, and close with DrawerLayout.closeDrawer