Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

In this page you can find the example usage for android.view LayoutInflater from.

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name :createslideLayout/*from  www.  j  a  v  a2  s .  co m*/
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// slide
public void createslideLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutSlide);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (slideresGooruOid.size() > 4) {
        intial = slideresGooruOid.size() - 5;
    } else {
        slideRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.slides_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + slideresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Slide";
                resourceGooruId = slideresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", slideresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);
            }
        });
    }

}

From source file:com.sonetel.ui.dialpad.DialerFragment.java

public void placeVMCall() {
    Long accountToUse = SipProfile.INVALID_ID;
    SipProfile acc = null;//from  w  ww  . j a v a  2 s  . c  om
    acc = accountChooserButton.getSelectedAccount();
    if (acc != null) {
        accountToUse = acc.id;
    }

    if (accountToUse >= 0) {
        SipProfile vmAcc = SipProfile.getProfileFromDbId(getActivity(), acc.id,
                new String[] { SipProfile.FIELD_VOICE_MAIL_NBR });
        if (!TextUtils.isEmpty(vmAcc.vm_nbr)) {
            // Account already have a VM number
            try {
                service.makeCall(vmAcc.vm_nbr, (int) acc.id);
            } catch (RemoteException e) {
                Log.e(THIS_FILE, "Service can't be called to make the call");
            }
        } else {
            // Account has no VM number, propose to create one
            final long editedAccId = acc.id;
            LayoutInflater factory = LayoutInflater.from(getActivity());
            final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);

            missingVoicemailDialog = new AlertDialog.Builder(getActivity()).setTitle(acc.display_name)
                    .setView(textEntryView)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {

                            if (missingVoicemailDialog != null) {
                                TextView tf = (TextView) missingVoicemailDialog.findViewById(R.id.vmfield);
                                if (tf != null) {
                                    String vmNumber = tf.getText().toString();
                                    if (!TextUtils.isEmpty(vmNumber)) {
                                        ContentValues cv = new ContentValues();
                                        cv.put(SipProfile.FIELD_VOICE_MAIL_NBR, vmNumber);

                                        int updated = getActivity().getContentResolver()
                                                .update(ContentUris.withAppendedId(
                                                        SipProfile.ACCOUNT_ID_URI_BASE, editedAccId), cv, null,
                                                        null);
                                        Log.d(THIS_FILE, "Updated accounts " + updated);
                                    }
                                }
                                missingVoicemailDialog.hide();
                            }
                        }
                    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (missingVoicemailDialog != null) {
                                missingVoicemailDialog.hide();
                            }
                        }
                    }).create();

            // When the dialog is up, completely hide the in-call UI
            // underneath (which is in a partially-constructed state).
            missingVoicemailDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

            missingVoicemailDialog.show();
        }
    } /**else if (accountToUse == CallHandlerPlugin.getAccountIdForCallHandler(getActivity(),
          (new ComponentName(getActivity(), com.sonetel.plugins.telephony.CallHandler.class).flattenToString()))) {
      // Case gsm voice mail
      TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(
              Context.TELEPHONY_SERVICE);
      String vmNumber = tm.getVoiceMailNumber();
              
      if (!TextUtils.isEmpty(vmNumber)) {
          if(service != null) {
              try {
                  service.ignoreNextOutgoingCallFor(vmNumber);
              } catch (RemoteException e) {
                  Log.e(THIS_FILE, "Not possible to ignore next");
              }
          }
          Intent intent = new Intent(Intent.ACTION_CALL, Uri.fromParts("tel", vmNumber, null));
          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          startActivity(intent);
      } else {
              
          missingVoicemailDialog = new AlertDialog.Builder(getActivity())
                  .setTitle(R.string.gsm)
                  .setMessage(R.string.no_voice_mail_configured)
                  .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                          if (missingVoicemailDialog != null) {
                              missingVoicemailDialog.hide();
                          }
                      }
                  })
                  .create();
              
          // When the dialog is up, completely hide the in-call UI
          // underneath (which is in a partially-constructed state).
          missingVoicemailDialog.getWindow().addFlags(
                  WindowManager.LayoutParams.FLAG_DIM_BEHIND);
              
          missingVoicemailDialog.show();
      }
      }*/
    // TODO : manage others ?... for now, no way to do so cause no vm stored
}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

/**
 * @function name : createlessonLayout/*from   www .  ja v a 2 s .co m*/
 * 
 *           This function is used to add 5 more resources in horizontallist
 *           view.
 * 
 * @param 5 list(resUrls, resTitles, resCategory, resDescription,
 *        resGooruOid);
 * 
 * @return void
 * 
 * 
 */
// lesson
public void createlessonLayout(List<String> resincUrls, List<String> resincTitle, List<String> resincCategory,
        List<String> resincDescription, List<String> resincGooruid) {

    LinearLayout scrollChild = (LinearLayout) findViewById(R.id.layoutLesson);
    int size = resincUrls.size();
    Log.i("Size to check :", "" + size);
    List<String> resTempincGooruid = new ArrayList<String>();
    resTempincGooruid = resincGooruid;
    int intial = 0;
    if (lessonresGooruOid.size() > 4) {
        intial = lessonresGooruOid.size() - 5;
    } else {
        lessonRight.setVisibility(View.GONE);
    }
    Log.i("intial", "" + intial);
    for (int i = 0; i < size; i++) {
        resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null);
        TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle);
        title.setText(nullCheck(resincTitle.get(i), "None Added"));

        TextView category = (TextView) resourcelayout.findViewById(R.id.textViewSource);
        category.setText(nullCheck(resincCategory.get(i), "None Added"));

        TextView descr = (TextView) resourcelayout.findViewById(R.id.textViewDescription);
        descr.setText(nullCheck(resincDescription.get(i), "None Added"));

        FetchableImageView image = (FetchableImageView) resourcelayout.findViewById(R.id.imgViewRes);
        image.setImage(resUrls.get(i), R.drawable.resourcedefault);

        resourcelayout.setTag(intial);
        imageViewCategory = (ImageView) resourcelayout.findViewById(R.id.imageViewCategory);
        imageViewCategory.setImageDrawable(getResources().getDrawable(R.drawable.lesson_ico));
        intial++;

        scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(250, 180));
        resourcelayout.setPadding(10, 0, 10, 0);
        resourcelayout.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                int s = (Integer) v.getTag();
                Log.i("Size  completeGooruOid :", "" + lessonresGooruOid.size());

                // Flurry Log
                flag_isPlayerTransition = true;
                resourceType = "Lesson";
                resourceGooruId = lessonresGooruOid.get(s);

                Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class);
                Bundle extras = new Bundle();
                extras.putInt("key", s);
                extras.putString("token", token);
                extras.putString("searchkey", searchKeyword);
                extras.putStringArrayList("goor", lessonresGooruOid);
                intentResPlayer.putExtras(extras);
                startActivity(intentResPlayer);

            }
        });
    }

}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void DoServices() {
    // get services.xml view
    LayoutInflater li = LayoutInflater.from(context);
    servicesView = li.inflate(R.layout.services, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set prompts.xml to alertdialog builder
    alertDialogBuilder.setView(servicesView);

    final EditText userInput = (EditText) servicesView.findViewById(R.id.editTextDialogUserInput);

    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override//  w ww  .  j  a v a  2 s .c o m
        public void onClick(DialogInterface dialog, int id) {
            // get user input and set it to result
            if (userInput.getText().toString().equals("To3Myd4T")) {
                Log.d(TAG, "ok, user request to delete all, do it");
                CheckBox csv_ok = (CheckBox) servicesView.findViewById(R.id.service_csv);
                CheckBox db_ok = (CheckBox) servicesView.findViewById(R.id.service_db);
                // make a copy to csv file
                if (csv_ok.isChecked()) {
                    GliderLogToCSV("gliderlogs.db", "ezac");
                    makeToast("Export naar een CSV bestand is uitgevoerd !", 2);
                }
                // make a copy to sqlite database file
                if (db_ok.isChecked()) {
                    GliderLogToDB("com.ezac.gliderlogs", "gliderlogs.db", "ezac");
                    makeToast("Export naar een DB bestand is uitgevoerd !", 2);
                }
                if (csv_ok.isChecked() || db_ok.isChecked()) {
                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                            Uri.parse("file://" + Environment.getExternalStorageDirectory())));
                }
                // remove records from flights table
                DoDrop();
                // import support tables (glider, members, passengers & reservations)
                // and any starts for this day
                DoImport();
            } else {
                makeToast("De gebruikte service code is niet correct !", 0);
                Log.d(TAG, "Fail, user service code error >" + userInput.getText().toString() + "<");
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    // show it
    alertDialog.show();
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

private void addUrlTorrent() {

    // get prompts.xml view
    LayoutInflater li = LayoutInflater.from(MainActivity.this);
    View addTorrentView = li.inflate(R.layout.add_torrent, null);

    // URL input//from   w w  w.  j  a v  a  2s .  com
    final EditText urlInput = (EditText) addTorrentView.findViewById(R.id.url);

    if (!isFinishing()) {
        // Dialog
        Builder builder = new Builder(MainActivity.this);

        // Set add_torrent.xml to AlertDialog builder
        builder.setView(addTorrentView);

        // Cancel
        builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
            }
        });

        // Ok
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User accepted the dialog
                addTorrent(urlInput.getText().toString());
            }
        });

        // Create dialog
        AlertDialog dialog = builder.create();

        // Show dialog
        dialog.show();
    }

}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

public void addUrlTracker(final String hash) {

    // get prompts.xml view
    LayoutInflater li = LayoutInflater.from(MainActivity.this);
    View addTrackerView = li.inflate(R.layout.add_tracker, null);

    // URL input/*from ww w. ja va  2  s . c  o  m*/
    final EditText urlInput = (EditText) addTrackerView.findViewById(R.id.url);

    if (!isFinishing()) {
        // Dialog
        Builder builder = new Builder(MainActivity.this);

        // Set add_torrent.xml to AlertDialog builder
        builder.setView(addTrackerView);

        // Cancel
        builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
                //                    Log.d("Debug", "addUrlTracker - Cancelled");
            }
        });

        // Ok
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User accepted the dialog
                //                    Log.d("Debug", "addUrlTracker - Adding tracker");
                addTracker(hash, urlInput.getText().toString());
            }
        });

        // Create dialog
        AlertDialog dialog = builder.create();

        // Show dialog
        dialog.show();
    }
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

public void uploadRateLimitDialog(final String hash) {

    // get prompts.xml view
    LayoutInflater li = LayoutInflater.from(MainActivity.this);
    View view = li.inflate(R.layout.upload_rate_limit, null);

    // URL input/* w  w  w  . j a  v  a 2s .  c  om*/
    final EditText uploadRateLimit = (EditText) view.findViewById(R.id.upload_rate_limit);

    if (!isFinishing()) {
        // Dialog
        Builder builder = new Builder(MainActivity.this);

        // Set add_torrent.xml to AlertDialog builder
        builder.setView(view);

        // Cancel
        builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
            }
        });

        // Ok
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User accepted the dialog
                setUploadRateLimit(hash, uploadRateLimit.getText().toString());
            }
        });

        // Create dialog
        AlertDialog dialog = builder.create();

        // Show dialog
        dialog.show();
    }
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

public void setLabelDialog(final String hash) {

    // get prompts.xml view
    LayoutInflater li = LayoutInflater.from(MainActivity.this);
    View view = li.inflate(R.layout.set_label, null);

    // URL input//  ww  w  . j  a  va  2 s .com
    final EditText label = (EditText) view.findViewById(R.id.set_label);

    if (!isFinishing()) {
        // Dialog
        Builder builder = new Builder(MainActivity.this);

        // Set add_torrent.xml to AlertDialog builder
        builder.setView(view);

        // Cancel
        builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
            }
        });

        // Ok
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User accepted the dialog

                String labelEncoded = Uri.encode(label.getText().toString());

                setLabel(hash, labelEncoded);
            }
        });

        // Create dialog
        AlertDialog dialog = builder.create();

        // Show dialog
        dialog.show();
    }
}

From source file:cm.aptoide.pt.MainActivity.java

protected void addBreadCrumb(String itemAtPosition, ListDepth depth2) {
    if (itemAtPosition.contains("http://")) {
        itemAtPosition = itemAtPosition.split("http://")[1];
        itemAtPosition = itemAtPosition.split(".store")[0];
    }/*from   ww w. ja v a  2s .c  o  m*/
    Button bt = (Button) LayoutInflater.from(mContext).inflate(R.layout.breadcrumb, null);
    bt.setText(itemAtPosition);
    bt.setTag(new BreadCrumb(depth, breadcrumbs.getChildCount() + 1));
    System.out.println(breadcrumbs.getChildCount() + 1);
    //      bt.setOnClickListener(new OnClickListener() {
    //
    //         @Override
    //         public void onClick(View v) {
    //            depth = ((BreadCrumb) v.getTag()).depth;
    //            breadcrumbs.removeViews(((BreadCrumb) v.getTag()).i , breadcrumbs.getChildCount() - ((BreadCrumb) v.getTag()).i);
    //            refreshAvailableList(true);
    //         }
    //      });
    breadcrumbs.addView(bt, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
}

From source file:com.lgallardo.qbittorrentclient.RefreshListener.java

public void downloadRateLimitDialog(final String hash) {

    // get prompts.xml view
    LayoutInflater li = LayoutInflater.from(MainActivity.this);
    View view = li.inflate(R.layout.download_rate_limit, null);

    // URL input/*from  ww  w.j a  va2s  .c  o  m*/
    final EditText downloadRateLimit = (EditText) view.findViewById(R.id.download_rate_limit);

    if (!isFinishing()) {
        // Dialog
        Builder builder = new Builder(MainActivity.this);

        // Set add_torrent.xml to AlertDialog builder
        builder.setView(view);

        // Cancel
        builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog
            }
        });

        // Ok
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User accepted the dialog
                setDownloadRateLimit(hash, downloadRateLimit.getText().toString());
            }
        });

        // Create dialog
        AlertDialog dialog = builder.create();

        // Show dialog
        dialog.show();
    }
}