Android examples for User Interface:TextView
add TextView to ViewGroup
//package com.java2s; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.TextView; public class Main { public static void addTextView(ViewGroup holder, String itemValue) { TextView itemView = new TextView(holder.getContext()); itemView.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); itemView.setText(itemValue);/*from w w w. j a v a 2 s . c o m*/ holder.addView(itemView); } public static void addTextView(ViewGroup holder, String itemName, String itemValue) { addTextView(holder, itemName + ": " + itemValue); } public static void addTextView(ViewGroup holder, String itemName, boolean itemValue) { addTextView(holder, itemName, String.valueOf(itemValue)); } public static void addTextView(ViewGroup holder, String itemName, int itemValue) { addTextView(holder, itemName, String.valueOf(itemValue)); } public static void addTextView(ViewGroup holder, String itemName, double itemValue) { addTextView(holder, itemName, String.valueOf(itemValue)); } }