Java Code Examples for android.widget.TextView

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/.

Source file: AboutDialog.java

  18 
vote

public static AlertDialog create(Context context) throws NameNotFoundException {
  PackageInfo pInfo=context.getPackageManager().getPackageInfo(context.getPackageName(),PackageManager.GET_META_DATA);
  String versionInfo=pInfo.versionName;
  String aboutTitle=String.format("About %s",context.getString(R.string.app_name));
  String versionString=String.format("Version: %s",versionInfo);
  String aboutText=context.getResources().getString(R.string.about_dialog_text);
  final TextView message=new TextView(context);
  final SpannableString s=new SpannableString(aboutText);
  message.setPadding(5,5,5,5);
  message.setText(versionString + "\n\n" + s);
  Linkify.addLinks(message,Linkify.ALL);
  message.setTextColor(Color.WHITE);
  return new AlertDialog.Builder(context).setTitle(aboutTitle).setCancelable(true).setIcon(R.drawable.icon).setPositiveButton(context.getString(android.R.string.ok),null).setView(message).create();
}
 

Example 2

From project 2Degrees-Toolbox, under directory /Toolbox/src/biz/shadowservices/DegreesToolbox/Preferences/.

Source file: WidgetPreferencesActivity.java

  18 
vote

@Override public void onResume(){
  super.onResume();
  widget=(WidgetInstance)getIntent().getSerializableExtra("widget");
  TextView widgetName=(TextView)findViewById(R.id.WidgetName);
  widgetName.setText(widget.toString());
  Gallery g=(Gallery)findViewById(R.id.gallery);
  Log.d(TAG,"background:" + widget.getSelectedBackgroundId(this));
  int background=widget.getSelectedBackgroundId(this);
  g.setSelection(background);
  ImageView preview=(ImageView)findViewById(R.id.previewImage);
  preview.setImageResource(Values.backgroundIds[background]);
  SeekBar s=(SeekBar)findViewById(R.id.transparencySeekBar);
  s.setProgress(widget.getTransparency(this));
}
 

Example 3

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarHelperBase.java

  18 
vote

/** 
 * {@inheritDoc}
 */
@Override public void onTitleChanged(CharSequence title,int color){
  TextView titleView=(TextView)mActivity.findViewById(R.id.actionbar_compat_title);
  if (titleView != null && !mUserTitle) {
    mTitle=title;
    if ((mDisplayOptions & DISPLAY_SHOW_TITLE) != 0) {
      titleView.setText(mTitle);
    }
  }
}
 

Example 4

From project ActionBarSherlock, under directory /samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: FragmentLayoutSupport.java

  18 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (container == null) {
    return null;
  }
  ScrollView scroller=new ScrollView(getActivity());
  TextView text=new TextView(getActivity());
  int padding=(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,4,getActivity().getResources().getDisplayMetrics());
  text.setPadding(padding,padding,padding,padding);
  scroller.addView(text);
  text.setText(Shakespeare.DIALOGUE[getShownIndex()]);
  return scroller;
}
 

Example 5

From project ActionBarSherlock, under directory /samples/known-bugs/src/com/actionbarsherlock/sample/knownbugs/.

Source file: Issue240.java

  18 
vote

/** 
 * The Fragment's UI is just a simple text view showing its instance number.
 */
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  TextView tv=new TextView(getActivity());
  tv.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT,MATCH_PARENT));
  tv.setText("Fragment #" + mNum);
  tv.setGravity(CENTER);
  return tv;
}
 

Example 6

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: RepoListFragment.java

  18 
vote

@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  setEmptyText(clickableWelcomeMessage());
  TextView emptyView=textViewForEmptyListText();
  makeLinksClickableIn(emptyView);
  emptyView.setPadding(20,20,20,20);
}
 

Example 7

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/.

Source file: AboutActivity.java

  18 
vote

@Override public View getChildView(int groupPosition,int childPosition,boolean isLastChild,View convertView,ViewGroup parent){
  if (convertView == null) {
    convertView=layoutInflater.inflate(R.layout.about_content,null);
  }
  String text=contents[groupPosition];
  Spanned spanned=Html.fromHtml(text);
  spanned=stripUnderlines(spanned);
  TextView view=(TextView)convertView.findViewById(R.id.content);
  view.setText(spanned);
  view.setMovementMethod(LinkMovementMethod.getInstance());
  return convertView;
}
 

Example 8

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/adapter/.

Source file: SessionAdapter.java

  18 
vote

private void fillTitle(View view,Context context,Session session){
  TextView sessionTitle=(TextView)view.findViewById(R.id.session_title);
  if (session.getTitle() != null && session.getTitle().length() > 0) {
    sessionTitle.setText(session.getTitle());
  }
 else {
    String unnamed=context.getString(R.string.unnamed_session);
    sessionTitle.setText(Html.fromHtml(unnamed));
  }
}
 

Example 9

From project Airports, under directory /src/com/nadmm/airports/.

Source file: ActivityBase.java

  18 
vote

protected void setContentMsg(String msg){
  TextView tv=new TextView(this);
  tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
  tv.setPadding(12,8,12,8);
  tv.setText(msg);
  setContentView(createContentView(tv));
}
 

Example 10

From project Airports, under directory /src/com/nadmm/airports/aeronav/.

Source file: ChartsDownloadActivity.java

  18 
vote

protected void showStatus(View row,int avail,int total){
  TextView tv=(TextView)row.findViewById(R.id.item_label);
  if (avail == total) {
    tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.btn_check_on_holo_light,0,0,0);
  }
 else {
    tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.btn_check_off_holo_light,0,0,0);
  }
}
 

Example 11

From project aksunai, under directory /src/org/androidnerds/app/aksunai/.

Source file: Aksunai.java

  18 
vote

public void initAdapter(){
  LayoutInflater inflate=(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View view=inflate.inflate(R.layout.server_row,getListView(),false);
  TextView title=(TextView)view.findViewById(R.id.server_title);
  TextView address=(TextView)view.findViewById(R.id.server_address);
  title.setText(R.string.new_server);
  address.setText(R.string.create_new_server);
  getListView().addHeaderView(view);
  mAdapter=new ServerListAdapter(this);
  mAdapter.loadData();
  setListAdapter(mAdapter);
}
 

Example 12

From project aksunai, under directory /src/org/androidnerds/app/aksunai/ui/.

Source file: ChatActivity.java

  18 
vote

public void onClick(View v){
  ChatView cv=(ChatView)mFlipper.getCurrentView();
  TextView chat=(TextView)v.findViewById(R.id.switcher_chat_title);
  ChatView c=getChatView(cv.mServerName,chat.getText().toString());
  int i=mFlipper.indexOfChild(c);
  mFlipper.setDisplayedChild(i);
  mChatSwitcher.dismiss();
  mChatSwitcher=null;
}
 

Example 13

From project AlarmApp-Android, under directory /src/org/alarmapp/activities/adapters/.

Source file: AlarmedUserAdapter.java

  18 
vote

@Override public View getView(AlarmedUser item,View row,ViewGroup parent){
  TextView tvName=(TextView)row.findViewById(R.id.tvTitle);
  ImageView ivStatus=(ImageView)row.findViewById(R.id.ivStatus);
  tvName.setText(item.getFullName());
  ivStatus.setImageLevel(item.getAlarmState().getId());
  return (row);
}
 

Example 14

From project AlarmApp-Android, under directory /src/org/alarmapp/activities/adapters/.

Source file: AlarmGroupsSpinnerAdapter.java

  18 
vote

@Override public View getDropDownView(int position,View convertView,ViewGroup parent){
  View row=super.getView(position,convertView,parent);
  TextView tvTitle=(TextView)row.findViewById(android.R.id.text1);
  tvTitle.setTextSize(30.0f);
  tvTitle.setText(getItem(position).getName());
  return row;
}
 

Example 15

From project alljoyn_java, under directory /samples/android/secure/service/src/org/alljoyn/bus/samples/secureservice/.

Source file: Service.java

  18 
vote

@Override protected void onPrepareDialog(int id,Dialog dialog){
switch (id) {
case DIALOG_ONE_TIME_PASSWORD:
{
      TextView textView=(TextView)dialog.findViewById(R.id.PasswordText);
      textView.setText(mPassword);
      break;
    }
default :
  break;
}
}
 

Example 16

From project 4308Cirrus, under directory /tendril-cirrus/src/main/java/edu/colorado/cs/cirrus/cirrus/.

Source file: UsageActivity.java

  17 
vote

@Override public void onStart(){
  super.onStart();
  User user=null;
  try {
    TextView username=(TextView)findViewById(R.id.user_profile_username);
    username.setText(user.getUserName().toString());
    TextView nameFirstLast=(TextView)findViewById(R.id.user_profile_name);
    nameFirstLast.setText(user.getFirstName() + " " + user.getLastName());
    TextView userEmail=(TextView)findViewById(R.id.user_profile_email);
    userEmail.setText(user.getEmailAddress());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  System.err.println(user);
}
 

Example 17

From project 4308Cirrus, under directory /tendril-example/src/main/java/edu/colorado/cs/cirrus/android/.

Source file: DeviceDetailActivity.java

  17 
vote

@Override public void onStart(){
  super.onStart();
  Devices devices=null;
  Bundle bundle=this.getIntent().getExtras();
  int deviceNumber=0;
  deviceNumber=bundle.getInt("deviceID");
  try {
    this.showLoadingProgressDialog();
    devices=tendril.fetchDevices();
    Device targetDevice=devices.getDevice().get(deviceNumber);
    TextView deviceName=(TextView)findViewById(R.id.device_name);
    deviceName.setText(targetDevice.getName());
    TextView deviceID=(TextView)findViewById(R.id.device_id);
    deviceID.setText(targetDevice.getDeviceId());
    TextView marketingName=(TextView)findViewById(R.id.device_marketing_name);
    marketingName.setText(targetDevice.getMarketingName());
    TextView networkID=(TextView)findViewById(R.id.device_network_id);
    networkID.setText(targetDevice.getNetworkId());
  }
 catch (  Exception e) {
    e.printStackTrace();
    Toast.makeText(getApplicationContext(),e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
  }
 finally {
    this.dismissProgressDialog();
  }
}
 

Example 18

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AAMain.java

  17 
vote

/** 
 * Called when the activity is created and put into memory. This is where all GUI elements should be set up and any other member variables that is used throughout the class
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  articles=new ArrayList<Article>();
  settings=this.getSharedPreferences("settings",0);
  AlarmReceiver.stopAlarm(this);
  adapter=new ArticleAdapter(this);
  this.setListAdapter(adapter);
  ib_refresh=(ImageButton)findViewById(R.id.ib_refresh);
  TextView tv=(TextView)findViewById(R.id.AATitle);
  Typeface face=Typeface.createFromAsset(getAssets(),"fonts/WREXHAM_.TTF");
  tv.setTypeface(face);
  finishReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      articles.clear();
      Bundle articleBundle=intent.getBundleExtra("articles");
      ArrayList<String> titles=articleBundle.getStringArrayList("titles");
      for (      String title : titles)       articles.add((Article)articleBundle.getSerializable(title));
      progressDialog.cancel();
      refresh();
    }
  }
;
  this.registerReceiver(finishReceiver,new IntentFilter("RSSFinish"));
  ib_refresh.setOnClickListener(new OnClickListener(){
    /** 
 * Handles when the user clicks the refresh button
 * @param v - view that was clicked
 */
    @Override public void onClick(    View v){
      runService();
    }
  }
);
  runService();
}
 

Example 19

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AASettings.java

  17 
vote

/** 
 * Called when the activity is created and put into memory. This is where all GUI elements should be set up and any other member variables that is used throughout the class
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.settings_main);
  TextView tv=(TextView)findViewById(R.id.AATitle);
  Typeface face=Typeface.createFromAsset(getAssets(),"fonts/WREXHAM_.TTF");
  tv.setTypeface(face);
  settings=this.getSharedPreferences("settings",0);
  adapter=new ColorAdapter(this);
  this.setListAdapter(adapter);
  ListView lv=getListView();
  lv.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      showDialog(position);
    }
  }
);
  sb_freq=(SeekBar)this.findViewById(R.id.sb_freq);
  tv_freq=(TextView)this.findViewById(R.id.tv_freq);
  sb_freq.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
    @Override public void onStopTrackingTouch(    SeekBar seekBar){
    }
    @Override public void onStartTrackingTouch(    SeekBar seekBar){
    }
    @Override public void onProgressChanged(    SeekBar seekBar,    int progress,    boolean fromUser){
      tv_freq.setText((progress + 1) + " hour(s)");
    }
  }
);
  sb_freq.setProgress((int)settings.getLong("freq",2) - 1);
}
 

Example 20

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: CommitDetailsFragment.java

  17 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  try {
    Repository repository=new FileRepository(gitDirFrom(getArguments()));
    ObjectId commitId=revisionIdFrom(repository,getArguments(),REVISION);
    Log.d(TAG,"onCreateView with " + commitId);
    View v=inflater.inflate(R.layout.commit_detail_view,container,false);
    CommitNavigationView commitNavigationView=(CommitNavigationView)v.findViewById(R.id.commit_navigation);
    commitNavigationView.setCommitSelectedListener(commitSelectedListener);
    PlotCommit<PlotLane> commit=commitSelectedListener.plotCommitFor(commitId);
    commitNavigationView.setCommit(commit);
    ((ObjectIdView)v.findViewById(R.id.commit_id)).setObjectId(commit);
    ViewGroup vg=(ViewGroup)v.findViewById(R.id.commit_people_group);
    PersonIdent author=commit.getAuthorIdent(), committer=commit.getCommitterIdent();
    if (author.equals(committer)) {
      addPerson("Author & Committer",author,vg);
    }
 else {
      addPerson("Author",author,vg);
      addPerson("Committer",committer,vg);
    }
    TextView textView=(TextView)v.findViewById(R.id.commit_message_text);
    textView.setText(commit.getFullMessage());
    return v;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
 

Example 21

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/utils/.

Source file: SimpleItemizedOverlay.java

  17 
vote

@Override protected boolean onTap(int index){
  Incident tappedIncident=(Incident)getItem(index);
  if (tappedIncident != null) {
    OverlayItem tapped=getItem(index);
    MapView.LayoutParams params=new MapView.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,tapped.getPoint(),LayoutParams.BOTTOM_CENTER);
    params.mode=MapView.LayoutParams.MODE_MAP;
    if (mBubbleView == null) {
      mBubbleView=((LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.view_map_bubble,null);
    }
    Log.d("AlerteVoirie_PM","state of incident : " + tappedIncident.state);
    if (tappedIncident.invalidations == 0 && tappedIncident.state != 'R') {
      mBubbleView.findViewById(R.id.Bubble_arrow).setVisibility(View.VISIBLE);
      mBubbleView.setOnClickListener(new OnClickListener(){
        @Override public void onClick(        View v){
          Intent i=new Intent(c,ReportDetailsActivity.class);
          i.putExtra("existing",true);
          i.putExtra("event",(String)mBubbleView.getTag());
          c.startActivity(i);
          clearBubble();
        }
      }
);
    }
 else {
      mBubbleView.findViewById(R.id.Bubble_arrow).setVisibility(View.GONE);
      mBubbleView.setOnClickListener(null);
    }
    TextView title=(TextView)mBubbleView.findViewById(R.id.TextView_title);
    TextView subtitle=(TextView)mBubbleView.findViewById(R.id.TextView_subtitle);
    title.setText(tappedIncident.description);
    subtitle.setText(tappedIncident.address);
    Log.d("AlerteVoirie_PM","tapped incident " + tappedIncident.toString());
    mBubbleView.setTag(tappedIncident.toString());
    mMapView.addView(mBubbleView,params);
    mMapView.getController().animateTo(tapped.getPoint());
    return true;
  }
  return super.onTap(index);
}
 

Example 22

From project Alerte-voirie-android, under directory /src/net/londatiga/android/.

Source file: QuickAction.java

  17 
vote

/** 
 * Get action item  {@link View}
 * @param title action item title
 * @param icon {@link Drawable} action item icon
 * @param listener {@link View.OnClickListener} action item listener
 * @return action item {@link View}
 */
private View getActionItem(String title,Drawable icon,OnClickListener listener){
  LinearLayout container=(LinearLayout)inflater.inflate(R.layout.action_item,null);
  ImageView img=(ImageView)container.findViewById(R.id.icon);
  TextView text=(TextView)container.findViewById(R.id.title);
  if (icon != null) {
    img.setImageDrawable(icon);
  }
 else {
    img.setVisibility(View.GONE);
  }
  if (title != null) {
    text.setText(title);
  }
 else {
    text.setVisibility(View.GONE);
  }
  if (listener != null) {
    container.setOnClickListener(listener);
  }
  return container;
}
 

Example 23

From project alljoyn_java, under directory /samples/android/chat/src/org/alljoyn/bus/sample/chat/.

Source file: DialogBuilder.java

  17 
vote

public Dialog createAllJoynErrorDialog(Activity activity,final ChatApplication application){
  Log.i(TAG,"createAllJoynErrorDialog()");
  final Dialog dialog=new Dialog(activity);
  dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
  dialog.setContentView(R.layout.alljoynerrordialog);
  TextView errorText=(TextView)dialog.findViewById(R.id.errorDescription);
  errorText.setText(application.getErrorString());
  Button yes=(Button)dialog.findViewById(R.id.errorOk);
  yes.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View view){
      dialog.cancel();
    }
  }
);
  return dialog;
}
 

Example 24

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarHelperBase.java

  16 
vote

/** 
 * Sets up the compatibility action bar with the given title.
 */
private void setupActionBar(){
  final ViewGroup actionBarCompat=getActionBarCompat();
  if (actionBarCompat == null) {
    return;
  }
  mHomeItem=new SimpleMenuItem(new SimpleMenu(mActivity),android.R.id.home,0,mActivity.getTitle());
  final LayoutInflater inflater=LayoutInflater.from(mActivity);
  mHomeLayout=(HomeView)inflater.inflate(R.layout.actionbar_compat_home,actionBarCompat,false);
  mHomeLayout.setOnClickListener(mUpClickListener);
  mHomeLayout.setClickable(true);
  mHomeLayout.setFocusable(true);
  mExpandedHomeLayout=(HomeView)inflater.inflate(R.layout.actionbar_compat_home,actionBarCompat,false);
  mExpandedHomeLayout.setUp(true);
  mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
  mExpandedHomeLayout.setContentDescription(mActivity.getResources().getText(R.string.action_bar_up_description));
  mExpandedHomeLayout.setFocusable(true);
  ApplicationInfo appInfo=mActivity.getApplicationInfo();
  PackageManager pm=mActivity.getPackageManager();
  try {
    mIcon=pm.getActivityIcon(mActivity.getComponentName());
  }
 catch (  NameNotFoundException e) {
    Log.e(TAG,"Activity component name not found!",e);
  }
  if (mIcon == null) {
    mIcon=appInfo.loadIcon(pm);
  }
  mHomeLayout.setIcon(mIcon);
  actionBarCompat.addView(mHomeLayout);
  LinearLayout.LayoutParams springLayoutParams=new LinearLayout.LayoutParams(0,ViewGroup.LayoutParams.FILL_PARENT);
  springLayoutParams.weight=1;
  mTitle=mActivity.getTitle();
  mTitleText=new TextView(mActivity,null,R.attr.actionbarCompatTitleStyle);
  mTitleText.setLayoutParams(springLayoutParams);
  mTitleText.setText(mTitle);
  actionBarCompat.addView(mTitleText);
  setDisplayOptions(DISPLAY_SHOW_HOME | DISPLAY_SHOW_TITLE);
}
 

Example 25

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: TutorialActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.tutorial);
  textView=(TextView)findViewById(R.id.turorial_text);
  butPrev=(Button)findViewById(R.id.prev_step);
  butPrev.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      prevAct();
    }
  }
);
  butNext=(Button)findViewById(R.id.next_step);
  butNext.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      nextAct();
    }
  }
);
  LinearLayout linearLayout=(LinearLayout)findViewById(R.id.tutorial_board_layout);
  tutorialBoardView=new TutorialBoardView(getApplicationContext());
  tutorialBoardView.setParent(this);
  initPiece();
  currentActIndex=0;
  updateTutorial();
  linearLayout.addView(tutorialBoardView);
}
 

Example 26

From project actionbar, under directory /src/com/kamalan/widget/.

Source file: ActionBar.java

  15 
vote

public void init(){
  mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  RelativeLayout barView=(RelativeLayout)mInflater.inflate(R.layout.actionbar,null);
  addView(barView);
  mProgress=(ProgressBar)barView.findViewById(R.id.actionbar_progress);
  mTitleView=(TextView)barView.findViewById(R.id.actionbar_title);
  mImageView=(ImageView)barView.findViewById(R.id.actionbar_menu);
  mImageView.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      actionbarClickedListener.eventOccured(v.getId());
    }
  }
);
  ibStage=(ImageButton)barView.findViewById(R.id.actionbar_stage);
  ibStage.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      actionbarClickedListener.eventOccured(v.getId());
    }
  }
);
}
 

Example 27

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: InfoAdapter.java

  15 
vote

@Override public View getView(final int position,final View convertView,final ViewGroup parent){
  ViewHolder holder;
  View view=convertView;
  if (view == null) {
    view=inflater.inflate(R.layout.widget_info_item,null);
    holder=new ViewHolder();
    holder.icon=(ImageView)view.findViewById(R.id.icon);
    holder.text=(TextView)view.findViewById(R.id.text);
    view.setTag(holder);
  }
 else {
    holder=(ViewHolder)view.getTag();
  }
  final InfoItem item=getItem(position);
  holder.icon.setImageResource(item.iconRes);
  holder.text.setText(resources.getString(item.textRes));
  return view;
}
 

Example 28

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: RssFeedAdapter.java

  15 
vote

@Override public View getView(final int position,final View convertView,final ViewGroup parent){
  ViewHolder holder;
  View view=convertView;
  if (view == null) {
    view=inflater.inflate(R.layout.widget_rss_item,null);
    holder=new ViewHolder();
    holder.title=(TextView)view.findViewById(R.id.title);
    holder.date=(TextView)view.findViewById(R.id.date);
    view.setTag(holder);
  }
 else {
    holder=(ViewHolder)view.getTag();
  }
  final FeedItem rssItem=getItem(position);
  if (rssItem != null) {
    holder.title.setText(rssItem.title);
    String formattedDate=rssItem.formattedDate;
    if (formattedDate == null) {
      if (rssItem.date != null) {
        rssItem.formattedDate=DateUtils.Formatter.FULL_DATE_FORMATTER.format(rssItem.date);
      }
 else {
        rssItem.formattedDate="";
      }
      formattedDate=rssItem.formattedDate;
    }
    holder.date.setText(formattedDate);
  }
  return view;
}