Created
March 5, 2014 21:05
-
-
Save csdear/53c0ef77e1a0cf4f5f3b to your computer and use it in GitHub Desktop.
Views : TextViews
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
| //Some exmaple view imports | |
| import android.view.Menu; | |
| import android.view.MenuItem; | |
| import android.view.View; | |
| import android.view.View.OnClickListener; | |
| import android.widget.ListView; | |
| import android.widget.TextView; | |
| //Creating textview fields | |
| private static TextView dateView; | |
| private static TextView timeView; | |
| //Initializing a textview field's value to a xml layout: | |
| dateView = (TextView) findViewById(R.id.date); | |
| timeView = (TextView) findViewById(R.id.time); | |
| //inflating a textView, onCreate() | |
| TextView <<tvInstanceName>> = (TextView) getLayoutInflater().inflate(R.<<tvXMLLayout>>, null); | |
| // Setting textview within a adapter/ITEM context. | |
| //1. Setting a TextView id'd element text value of an ITEM within a layout | |
| //1a. Instanced layout object's view set to XML layout for ITEM. | |
| RelativeLayout itemLayout = (RelativeLayout) LayoutInflater.from( | |
| mContext).inflate(R.layout.todo_item, null); | |
| //1b. Setting the text to a specific textview . | |
| final TextView titleView = (TextView) itemLayout.findViewById(R.id.titleView); | |
| titleView.setText(<<externalCLassName>>.getTitle()); | |
| //1c. Defined elsewhere <<externalClassName>>, such as methods for ITEM. | |
| public String getTitle() { | |
| return mTitle; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment