Created
March 5, 2014 20:13
-
-
Save csdear/877aef58ddca7c600a4f to your computer and use it in GitHub Desktop.
Inflate
Inflates a view or layout in the onCreate method or getView()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Required Import | |
| import android.view.LayoutInflater; | |
| //Inflating a view within the onCreate method | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| //TODO - Ex., Inflate footerView for footer_view.xml file | |
| TextView <<tvInstanceName>> = (TextView) getLayoutInflater().inflate(R.layout.<<viewXMLlayout>>, null); | |
| getListView().addFooterView(footerView); | |
| } | |
| // Creating a view to display an ITEM. Inflating a layout in the getView() | |
| public View getView(int position, View convertView, ViewGroup parent) { | |
| //Getting the current item. | |
| final ToDoItem toDoItem = (ToDoItem) getItem(position); | |
| //Inflating a view for the ITEM. | |
| RelativeLayout itemLayout = (RelativeLayout) LayoutInflater.from( | |
| mContext).inflate(R.layout.todo_item, null); | |
| // final TextView titleView = null; | |
| final TextView titleView = (TextView) itemLayout | |
| .findViewById(R.id.titleView); | |
| titleView.setText(toDoItem.getTitle()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment