stuart-d2
3/5/2014 - 9:05 PM

Views : TextViews

Views : TextViews

//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;
	}