Java Code Examples for android.view.LayoutInflater

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 actionbar, under directory /actionbar-library/src/main/java/com/github/erd/actionbar/widget/.

Source file: Actionbar.java

  19 
vote

/** 
 * Add a button to the action bar.
 * @param icon Image icon to use.
 */
public void addActionButton(int icon){
  ActionbarButton btn;
  ActionbarDivider div;
  LayoutInflater inflater=getLayoutInflater();
  btn=(ActionbarButton)inflater.inflate(R.layout.actionbar_button,root,false);
  div=(ActionbarDivider)inflater.inflate(R.layout.actionbar_divider,root,false);
  btn.setButtonIcon(icon);
  btn.setOnClickListener(item_click);
  root.addView(div);
  root.addView(btn);
}
 

Example 2

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: MenuItemImpl.java

  18 
vote

public MenuItem setActionView(int resId){
  final Context context=mMenu.getContext();
  final LayoutInflater inflater=LayoutInflater.from(context);
  setActionView(inflater.inflate(resId,new LinearLayout(context),false));
  return this;
}
 

Example 3

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: MenuItemImpl.java

  18 
vote

public MenuItem setActionView(int resId){
  final Context context=mMenu.getContext();
  final LayoutInflater inflater=LayoutInflater.from(context);
  setActionView(inflater.inflate(resId,new LinearLayout(context),false));
  return this;
}
 

Example 4

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

Source file: SimpleMenuItem.java

  18 
vote

public MenuItem setActionView(int resId){
  final Context context=mMenu.getContext();
  final LayoutInflater inflater=LayoutInflater.from(context);
  setActionView(inflater.inflate(resId,null));
  return this;
}
 

Example 5

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/view/menu/.

Source file: MenuItemImpl.java

  18 
vote

public MenuItem setActionView(int resId){
  final Context context=mMenu.getContext();
  final LayoutInflater inflater=LayoutInflater.from(context);
  setActionView(inflater.inflate(resId,new LinearLayout(context),false));
  return this;
}
 

Example 6

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 7

From project AlarmApp-Android, under directory /src/org/alarmapp/util/adapter/.

Source file: AbstractArrayAdapter.java

  18 
vote

@Override public View getView(int position,View convertView,ViewGroup parent){
  View row=convertView;
  if (row == null) {
    LayoutInflater inflater=activity.getLayoutInflater();
    row=inflater.inflate(layoutId,parent,false);
  }
  T item=getItem(position);
  return getView(item,row,parent);
}
 

Example 8

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: MenuItemImpl.java

  18 
vote

public MenuItem setActionView(int resId){
  final Context context=mMenu.getContext();
  final LayoutInflater inflater=LayoutInflater.from(context);
  setActionView(inflater.inflate(resId,new LinearLayout(context),false));
  return this;
}
 

Example 9

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/cwac/endless/.

Source file: EndlessAdapter.java

  18 
vote

/** 
 * Inflates pending view using the pendingResource ID passed into the constructor
 * @param parent
 * @return inflated pending view, or null if the context passed into the pending view constructor was null.
 */
protected View getPendingView(ViewGroup parent){
  if (context != null) {
    LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return inflater.inflate(pendingResource,parent,false);
  }
  throw new RuntimeException("You must either override getPendingView() or supply a pending View resource via the constructor");
}
 

Example 10

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/view/menu/.

Source file: MenuItemImpl.java

  18 
vote

public MenuItem setActionView(int resId){
  final Context context=mMenu.getContext();
  final LayoutInflater inflater=LayoutInflater.from(context);
  setActionView(inflater.inflate(resId,new LinearLayout(context),false));
  return this;
}
 

Example 11

From project Android, under directory /app/src/main/java/com/github/mobile/ui/commit/.

Source file: CommitCompareListFragment.java

  18 
vote

@Override public void onViewCreated(View view,Bundle savedInstanceState){
  super.onViewCreated(view,savedInstanceState);
  LayoutInflater inflater=getActivity().getLayoutInflater();
  list.setOnItemClickListener(this);
  adapter=new HeaderFooterListAdapter<CommitFileListAdapter>(list,new CommitFileListAdapter(inflater,diffStyler,null,null));
  adapter.addFooter(inflater.inflate(layout.footer_separator,null));
  list.setAdapter(adapter);
}
 

Example 12

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: MainActivity.java

  18 
vote

@Override protected void onCreate(){
  final LayoutInflater inflater=(LayoutInflater)this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  final ViewGroup root=(ViewGroup)inflater.inflate(R.layout.popup_bank,null);
  root.findViewById(R.id.btnRefresh).setOnClickListener(this);
  root.findViewById(R.id.btnWWW).setOnClickListener(this);
  root.findViewById(R.id.btnEdit).setOnClickListener(this);
  root.findViewById(R.id.btnRemove).setOnClickListener(this);
  this.setContentView(root);
}
 

Example 13

From project android-client_2, under directory /src/org/mifos/androidclient/main/views/adapters/.

Source file: CollectionSheetExpandableListAdapter.java

  18 
vote

@Override public View getChildView(int groupPosition,int childPosition,boolean isLastChild,View convertView,ViewGroup parent){
  View row;
  CollectionSheetCustomer customer=(CollectionSheetCustomer)getChild(groupPosition,childPosition);
  if (customer == null) {
    row=new TextView(mContext);
  }
 else {
    LayoutInflater inflater=(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    row=inflater.inflate(R.layout.collection_sheet_child,parent,false);
    TextView textView=(TextView)row.findViewById(R.id.collectionSheetChild_name);
    textView.setText("     " + customer.getName());
  }
  return row;
}
 

Example 14

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

Source file: AASettings.java

  17 
vote

/** 
 * Creates and returns the current view in the list
 */
@Override public View getView(int position,View convertView,ViewGroup parent){
  LayoutInflater inflater=AASettings.this.getLayoutInflater();
  SharedPreferences settings=AASettings.this.settings;
  View row;
  if (convertView == null)   row=inflater.inflate(R.layout.color_row,null);
 else   row=convertView;
  TextView tv_colorType=(TextView)row.findViewById(R.id.tv_colorType);
  ImageView iv_colorDisplay=(ImageView)row.findViewById(R.id.iv_colorDiplay);
  DisplayTypes[] displayTypes=DisplayTypes.values();
  ColorDrawable color=new ColorDrawable(settings.getInt(displayTypes[position].toString(),getDefaultColor(position)));
  iv_colorDisplay.setBackgroundResource(R.drawable.topbar);
  iv_colorDisplay.setImageDrawable(color);
  tv_colorType.setText(this.getItem(position));
  return row;
}
 

Example 15

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

Source file: Client.java

  17 
vote

@Override protected Dialog onCreateDialog(int id){
switch (id) {
case DIALOG_LOGON:
    LayoutInflater factory=LayoutInflater.from(this);
  final View view=factory.inflate(R.layout.logon_dialog,null);
return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.logon_dialog).setCancelable(false).setView(view).setPositiveButton(R.string.dialog_ok,new DialogInterface.OnClickListener(){
  public void onClick(  DialogInterface dialog,  int id){
    mUserName=((EditText)view.findViewById(R.id.UserNameEditText)).getText().toString();
    mPassword=((EditText)view.findViewById(R.id.PasswordEditText)).getText().toString();
    mLatch.countDown();
  }
}
).create();
default :
return null;
}
}
 

Example 16

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/bookmark/.

Source file: BookmarkItemAdapter.java

  17 
vote

@Override public View getView(int position,View convertView,ViewGroup parent){
  BookmarkDto item=getItem(position);
  TwoLineListItem view;
  if (convertView == null) {
    LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view=(TwoLineListItem)inflater.inflate(resource,parent,false);
  }
 else {
    view=(TwoLineListItem)convertView;
  }
  if (view.getText1() != null) {
    String key=item.getKey().getName();
    view.getText1().setText(key);
  }
  if (view.getText2() != null) {
    try {
      String verseText=bookmarkControl.getBookmarkVerseText(item);
      view.getText2().setText(verseText);
    }
 catch (    Exception e) {
      Log.e(TAG,"Error loading label verse text",e);
      view.getText2().setText("");
    }
  }
  return view;
}
 

Example 17

From project android-client, under directory /xwiki-android-client/src/org/xwiki/android/client/blog/.

Source file: Blogger.java

  17 
vote

private void showRetreiveDialog(){
  ret_dialog=new Dialog(this);
  ret_dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
  ret_dialog.setTitle("Page to retreive");
  LayoutInflater li=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View dialogView=li.inflate(R.layout.blog_retreive_dialog,null);
  ret_dialog.setContentView(dialogView);
  ret_dialog.show();
  Button okBtn=(Button)dialogView.findViewById(R.id.blg_ret_btn_ok);
  etPageName=(EditText)dialogView.findViewById(R.id.blg_ret_et_pageName);
  okBtn.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      DocumentReference dref=new DocumentReference("xwiki","Blog",etPageName.getText().toString());
      DocumentRemoteSvcCallbacks clbk=new DocumentRemoteSvcCallbacks(){
        @Override public void onFullyRetreived(        Document res,        boolean success,        RaoException ex){
          if (success) {
            ret_dialog.dismiss();
            progDialog.dismiss();
            Intent i=new Intent(Blogger.this,EditPostActivity.class);
            i.putExtra(EditPostActivity.ARG_UPDATE_DOC,res);
            startActivity(i);
          }
 else {
            progDialog.dismiss();
          }
        }
      }
;
      progDialog=ProgressDialog.show(Blogger.this,"Processing","Fetching document from server");
      dsvc.retreive(dref,clbk);
    }
  }
);
}
 

Example 18

From project android-context, under directory /defunct/.

Source file: ContextBrowserActivity.java

  17 
vote

private void add(){
  LayoutInflater inflater=LayoutInflater.from(this);
  View addView=inflater.inflate(R.layout.add_edit,null);
  final DialogWrapper wrapper=new DialogWrapper(addView);
  new AlertDialog.Builder(this).setTitle(R.string.add_context).setView(addView).setPositiveButton(R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
      processAdd(wrapper);
    }
  }
).setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int whichButton){
    }
  }
).show();
}
 

Example 19

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: ApplicationBackup.java

  17 
vote

@Override public View getView(int position,View convertView,ViewGroup parent){
  AppViewHolder holder;
  ApplicationInfo info=mAppList.get(position);
  if (convertView == null) {
    LayoutInflater inflater=getLayoutInflater();
    convertView=inflater.inflate(R.layout.tablerow,parent,false);
    holder=new AppViewHolder();
    holder.top_view=(TextView)convertView.findViewById(R.id.top_view);
    holder.bottom_view=(TextView)convertView.findViewById(R.id.bottom_view);
    holder.check_mark=(ImageView)convertView.findViewById(R.id.multiselect_icon);
    holder.icon=(ImageView)convertView.findViewById(R.id.row_image);
    holder.icon.setMaxHeight(40);
    convertView.setTag(holder);
  }
 else {
    holder=(AppViewHolder)convertView.getTag();
  }
  holder.top_view.setText(info.processName);
  holder.bottom_view.setText(info.packageName);
  try {
    holder.icon.setImageDrawable(mPackMag.getApplicationIcon(info.packageName));
  }
 catch (  NameNotFoundException e) {
    holder.icon.setImageResource(R.drawable.appicon);
  }
  return convertView;
}
 

Example 20

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: BluetoothActivity.java

  17 
vote

@Override public View getView(int position,View view,ViewGroup parent){
  String name;
  int classType;
  if (view == null) {
    LayoutInflater in=(LayoutInflater)BluetoothActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view=in.inflate(R.layout.grid_content_layout,parent,false);
    mHolder=new DataViewHolder();
    mHolder.mIcon=(ImageView)view.findViewById(R.id.content_icon);
    mHolder.mMainText=(TextView)view.findViewById(R.id.content_text);
    view.setTag(mHolder);
  }
 else {
    mHolder=(DataViewHolder)view.getTag();
  }
  name=mDeviceData.get(position);
  if (!name.equals("No Devices")) {
    classType=Integer.valueOf(name.substring(name.lastIndexOf(":") + 1,name.length()));
    if ((classType & 0x200) > 0)     mHolder.mIcon.setImageResource(R.drawable.cellphone);
    if ((classType & 0x100) > 0)     mHolder.mIcon.setImageResource(R.drawable.computer);
    mHolder.mMainText.setText(name.substring(0,name.lastIndexOf(":")));
  }
 else {
    mHolder.mIcon.setImageResource(R.drawable.computer);
    mHolder.mMainText.setText(name);
  }
  mHolder.mMainText.setMaxLines(5);
  return view;
}
 

Example 21

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

Source file: InfoAdapter.java

  15 
vote

public InfoAdapter(final Context context,final List<InfoItem> list){
  super();
  this.list=list;
  this.context=context.getApplicationContext();
  this.resources=context.getResources();
  this.inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 

Example 22

From project agit, under directory /agit/src/main/java/com/handmark/pulltorefresh/library/support/.

Source file: PullToRefreshListLoadingFragment.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View layout=super.onCreateView(inflater,container,savedInstanceState);
  ListView lv=(ListView)layout.findViewById(android.R.id.list);
  ViewGroup parent=(ViewGroup)lv.getParent();
  for (int i=0, z=parent.getChildCount(); i < z; i++) {
    View child=parent.getChildAt(i);
    if (child == lv) {
      parent.removeViewAt(i);
      mPullToRefreshListView=new PullToRefreshListView(getActivity());
      parent.addView(mPullToRefreshListView,i,lv.getLayoutParams());
      break;
    }
  }
  return layout;
}
 

Example 23

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

Source file: DtppActivity.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.dtpp_detail_view,container,false);
  Button btnDownload=(Button)view.findViewById(R.id.btnDownload);
  btnDownload.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      getAptCharts();
    }
  }
);
  Button btnDelete=(Button)view.findViewById(R.id.btnDelete);
  btnDelete.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      checkDelete();
    }
  }
);
  return view;
}
 

Example 24

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

Source file: JSONAdapter.java

  15 
vote

public JSONAdapter(Context context,JSONArray data,int cellLayout,String[] from,int[] to,String jsonObjectName){
  this.data=data;
  this.cellLayout=cellLayout;
  this.from=from;
  this.to=to;
  this.jsonObjectName=jsonObjectName;
  inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 

Example 25

From project android-api-demos, under directory /src/com/mobeelizer/demos/adapters/.

Source file: ConflictsSyncAdapter.java

  15 
vote

public ConflictsSyncAdapter(final Context context,final List<ConflictsEntity> objects){
  super(context,R.layout.itemized_list_item,R.id.listItemLowerText,objects);
  mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  mParams=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  mStar=context.getResources().getDrawable(R.drawable.ic_star);
}
 

Example 26

From project Android-FFXIEQ, under directory /ffxieq/src/com/github/kanata3249/ffxieq/android/.

Source file: BlueMagicSetView.java

  15 
vote

@Override public View getView(int position,View convertView,ViewGroup parent){
  View v=convertView;
  if (v == null) {
    v=((LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.bluemagiclistview,null);
  }
  if (mMagics[position].mEnable == false) {
    ((TextView)v.findViewById(R.id.Name)).setText("");
    ((TextView)v.findViewById(R.id.Element)).setText("");
    ((TextView)v.findViewById(R.id.Abissea)).setText("");
    ((TextView)v.findViewById(R.id.VW)).setText("");
    ((TextView)v.findViewById(R.id.BP)).setText("");
    ((TextView)v.findViewById(R.id.Name)).setHint(mMagics[position].mName);
    ((TextView)v.findViewById(R.id.Element)).setHint(mMagics[position].mElement);
    ((TextView)v.findViewById(R.id.Abissea)).setHint(mMagics[position].mWeaknessA ? "A" : "");
    ((TextView)v.findViewById(R.id.VW)).setHint(mMagics[position].mWeaknessVW ? "V" : "");
    ((TextView)v.findViewById(R.id.BP)).setHint(String.format("%d",mMagics[position].mBP));
  }
 else {
    ((TextView)v.findViewById(R.id.Name)).setText(mMagics[position].mName);
    ((TextView)v.findViewById(R.id.Element)).setText(mMagics[position].mElement);
    ((TextView)v.findViewById(R.id.Abissea)).setText(mMagics[position].mWeaknessA ? "A" : "");
    ((TextView)v.findViewById(R.id.VW)).setText(mMagics[position].mWeaknessVW ? "V" : "");
    ((TextView)v.findViewById(R.id.BP)).setText(String.format("%d",mMagics[position].mBP));
  }
  return v;
}