Java Code Examples for android.app.Activity#getLayoutInflater()

The following examples show how to use android.app.Activity#getLayoutInflater() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceListAdapter.java    From BLEService with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DeviceListAdapter(Activity par) {
	super();
	mDevices  = new ArrayList<BluetoothDevice>();
	mRecords = new ArrayList<byte[]>();
	mRSSIs = new ArrayList<Integer>();
	mInflater = par.getLayoutInflater();
}
 
Example 2
Source File: ToastUtils.java    From PaymentKit-Droid with Apache License 2.0 5 votes vote down vote up
private static Toast makeToast(Activity activity, String text, int duration) {
	LayoutInflater inflater = activity.getLayoutInflater();
	View layout = inflater.inflate(R.layout.pk_toast, (ViewGroup) activity.findViewById(R.id.toast_layout_root));
	TextView textView = (TextView) layout.findViewById(R.id.text);
	textView.setText(text);
	Toast toast = new Toast(activity);
	toast.setGravity(Gravity.CENTER, 0, 0);
	toast.setDuration(duration);
	toast.setView(layout);
	return toast;
}
 
Example 3
Source File: SpinnerAdapter.java    From uservoice-android-sdk with MIT License 5 votes vote down vote up
public SpinnerAdapter(Activity context, List<T> objects) {
    this.objects = objects;
    inflater = context.getLayoutInflater();
    TypedValue tv = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, tv, true);
    color = context.getResources().getColor(tv.resourceId);
}
 
Example 4
Source File: RecentListAdapter.java    From music_player with Open Software License 3.0 5 votes vote down vote up
private void searchForAlbum(final Activity context, final int position) {
    menu_position = position;
    LayoutInflater inflater = context.getLayoutInflater();
    final View pre_search_for_album = inflater.inflate(R.layout.pre_search_for_album, (ViewGroup) context.findViewById(R.id.pre_search_for_album));
    final EditText title = (EditText) pre_search_for_album.findViewById(R.id.search_for_album_title);
    final EditText singer = (EditText) pre_search_for_album.findViewById(R.id.search_for_album_singer);
    title.setText(Datesublist.get(position).getMusicTitle());
    singer.setText(Datesublist.get(position).getMusicArtist());
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("请输入搜索内容");
    builder.setPositiveButton("继续", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (title.getText().toString().equals("") || singer.getText().toString().equals("")){
                Toast.makeText(context, "歌曲名和歌手名均不能为空", Toast.LENGTH_SHORT).show();
            }else {
                new matchTask().execute(title.getText().toString()+singer.getText().toString());
            }

        }
    });
    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    });
    builder.setView(pre_search_for_album);
    builder.setCancelable(false);
    builder.show();
}
 
Example 5
Source File: BluetoothDeviceAdapter.java    From thermalprinterhelper with Apache License 2.0 5 votes vote down vote up
public BluetoothDeviceAdapter(Activity context, List<BluetoothDevice> list) {
    super(context, R.layout.item_bluetoothdevice , list);
    this.context = context;
    allData = new ArrayList<BluetoothDevice>();
    this.selectedList = new ArrayList<Integer>();
    if(list != null)
        allData.addAll(list);

    preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
    mInflater = context.getLayoutInflater();

    refreshDevicAddress();
}
 
Example 6
Source File: searchAdapter.java    From music_player with Open Software License 3.0 5 votes vote down vote up
private void addTo(final Activity context, final int position) {
    LayoutInflater inflater = context.getLayoutInflater();
    final View addtolist_dialog = inflater.inflate(R.layout.addtolist, (ViewGroup) context.findViewById(R.id.addtolist_dialog));
    final AlertDialog dialog = showAddtolistDialog(addtolist_dialog, context, position);
    View createlist = addtolist_dialog.findViewById(R.id.create_list);
    createlist.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
            showCreateListDialog(context, view);
        }
    });
}
 
Example 7
Source File: MatchTemplate.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void addMetaData(final Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.match_meta_dialog_add_edit_data, null);
    final AlertDialog dialog = new AlertDialog.Builder(activity)
            .setTitle(R.string.comprehension_add_meta_title)
            .setView(dialogView,
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_left),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_top),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_right),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_bottom))
            .setPositiveButton(R.string.info_template_add, null)
            .setNegativeButton(R.string.info_template_cancel, null)
            .create();
    dialog.show();

    final EditText title = (EditText) dialogView.findViewById(R.id.meta_title);
    final EditText first_list_title = (EditText) dialogView.findViewById(R.id.meta_first_list_title);
    final EditText second_list_title = (EditText) dialogView.findViewById(R.id.meta_second_list_title);

    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (validated(activity, title, first_list_title, second_list_title)) {

                String titleText = title.getText().toString().trim();
                String first_list_titleText = first_list_title.getText().toString().trim();
                String second_list_titleText = second_list_title.getText().toString().trim();
                MatchMetaModel temp = new MatchMetaModel(titleText, first_list_titleText, second_list_titleText);
                metaData.add(temp);
                setEmptyView(activity);
                metaAdapter.notifyDataSetChanged();
                dialog.dismiss();
            }
        }
    });
}
 
Example 8
Source File: ApolloUtils.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * @return A custom ContextMenu header
 */
public static  View setHeaderLayout(String Type, Cursor cursor, Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View header = inflater.inflate(R.layout.music_context_menu_header, null, false);

    // Artist image
    final ImageView mHanderImage = (ImageView)header.findViewById(R.id.header_image);
    String albumId="",artistName="",albumName="";

    if(Type == TYPE_ALBUM){
        albumName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ALBUM));
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(AlbumColumns.ARTIST));
        albumId = cursor.getString(cursor.getColumnIndexOrThrow(BaseColumns._ID));
    }
    else{
        artistName = cursor.getString(cursor.getColumnIndexOrThrow(ArtistColumns.ARTIST));
    }
    
    
    ImageInfo mInfo = new ImageInfo();
    mInfo.type = Type;
    mInfo.size = SIZE_THUMB;
    mInfo.source = SRC_FIRST_AVAILABLE;
    mInfo.data = (Type == TYPE_ALBUM ? new String[]{ albumId , artistName, albumName } : new String[]{ artistName});
   
    ImageProvider.getInstance(activity).loadImage( mHanderImage, mInfo );

    // Set artist name
    TextView headerText = (TextView)header.findViewById(R.id.header_text);
    headerText.setText( (Type == TYPE_ALBUM ? albumName : artistName));
    headerText.setBackgroundColor((activity).getResources().getColor(R.color.transparent_black));
    return header;
}
 
Example 9
Source File: SavedWallpaperImages.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
public SavedWallpaperImages(Activity context) {
    // We used to store the saved images in the cache directory, but that meant they'd get
    // deleted sometimes-- move them to the data directory
    ImageDb.moveFromCacheDirectoryIfNecessary(context);
    mDb = new ImageDb(context);
    mContext = context;
    mLayoutInflater = context.getLayoutInflater();
}
 
Example 10
Source File: Card.java    From android-BatchStepSensor with Apache License 2.0 5 votes vote down vote up
public Card build(Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    // Inflating the card.
    ViewGroup cardView = (ViewGroup) inflater.inflate(mCard.mLayoutId,
            (ViewGroup) activity.findViewById(R.id.card_stream), false);

    // Check that the layout contains a TextView with the card_title id
    View viewTitle = cardView.findViewById(R.id.card_title);
    if (mCard.mTitle != null && viewTitle != null) {
        mCard.mTitleView = (TextView) viewTitle;
        mCard.mTitleView.setText(mCard.mTitle);
    } else if (viewTitle != null) {
        viewTitle.setVisibility(View.GONE);
    }

    // Check that the layout contains a TextView with the card_content id
    View viewDesc = cardView.findViewById(R.id.card_content);
    if (mCard.mDescription != null && viewDesc != null) {
        mCard.mDescView = (TextView) viewDesc;
        mCard.mDescView.setText(mCard.mDescription);
    } else if (viewDesc != null) {
        cardView.findViewById(R.id.card_content).setVisibility(View.GONE);
    }


    ViewGroup actionArea = (ViewGroup) cardView.findViewById(R.id.card_actionarea);

    // Inflate Progress
    initializeProgressView(inflater, actionArea);

    // Inflate all action views.
    initializeActionViews(inflater, cardView, actionArea);

    mCard.mCardView = cardView;
    mCard.mOverlayView = cardView.findViewById(R.id.card_overlay);

    return mCard;
}
 
Example 11
Source File: FastScrollListAdapter.java    From music_player with Open Software License 3.0 5 votes vote down vote up
private void searchForAlbum(final Activity context, final int position) {
    menu_position = position;
    LayoutInflater inflater = context.getLayoutInflater();
    final View pre_search_for_album = inflater.inflate(R.layout.pre_search_for_album, (ViewGroup) context.findViewById(R.id.pre_search_for_album));
    final EditText title = (EditText) pre_search_for_album.findViewById(R.id.search_for_album_title);
    final EditText singer = (EditText) pre_search_for_album.findViewById(R.id.search_for_album_singer);
    title.setText(musicInfoArrayList.get(position).getMusicTitle());
    singer.setText(musicInfoArrayList.get(position).getMusicArtist());
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("请输入搜索内容");
    builder.setPositiveButton("继续", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (title.getText().toString().equals("") || singer.getText().toString().equals("")){
                Toast.makeText(context, "歌曲名和歌手名均不能为空", Toast.LENGTH_SHORT).show();
            }else {
                new matchTask().execute(title.getText().toString()+singer.getText().toString());
            }

        }
    });
    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    });
    builder.setView(pre_search_for_album);
    builder.setCancelable(false);
    builder.show();
}
 
Example 12
Source File: FavouriteListAdapter.java    From music_player with Open Software License 3.0 5 votes vote down vote up
private void searchForAlbum(final Activity context, final int position) {
    menu_position = position;
    LayoutInflater inflater = context.getLayoutInflater();
    final View pre_search_for_album = inflater.inflate(R.layout.pre_search_for_album, (ViewGroup) context.findViewById(R.id.pre_search_for_album));
    final EditText title = (EditText) pre_search_for_album.findViewById(R.id.search_for_album_title);
    final EditText singer = (EditText) pre_search_for_album.findViewById(R.id.search_for_album_singer);
    title.setText(Timessublist.get(position).getMusicTitle());
    singer.setText(Timessublist.get(position).getMusicArtist());
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("请输入搜索内容");
    builder.setPositiveButton("继续", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (title.getText().toString().equals("") || singer.getText().toString().equals("")){
                Toast.makeText(context, "歌曲名和歌手名均不能为空", Toast.LENGTH_SHORT).show();
            }else {
                new matchTask().execute(title.getText().toString()+singer.getText().toString());
            }

        }
    });
    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    });
    builder.setView(pre_search_for_album);
    builder.setCancelable(false);
    builder.show();
}
 
Example 13
Source File: DialogManager.java    From Expense-Tracker-App with MIT License 4 votes vote down vote up
public AlertDialog createEditTextDialog(Activity activity, String title, String confirmText, String negativeText, final DialogInterface.OnClickListener listener) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogLayout = inflater.inflate(R.layout.layout_dialog_edit_text, null);
    return createAlertDialog(activity, title, dialogLayout, null, confirmText, negativeText, listener);
}
 
Example 14
Source File: VideoCollectionTemplate.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void editItem(final Activity activity, final int position) {

    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.video_dialog_edit_data, null);
    final AlertDialog dialog = new AlertDialog.Builder(activity)
            .setTitle(R.string.info_edit_title)
            .setView(dialogView,
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_left),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_top),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_right),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_bottom))
            .setPositiveButton(R.string.info_template_ok, null)
            .setNegativeButton(R.string.info_template_cancel, null)
            .create();
    dialog.show();

    final VideoModel data = videoData.get(position);

    final ImageView thumb = (ImageView) dialogView.findViewById(R.id.thumb);
    final EditText title = (EditText) dialogView.findViewById(R.id.video_title);
    final EditText description = (EditText) dialogView.findViewById(R.id.video_description);
    final EditText link = (EditText) dialogView.findViewById(R.id.video_link);

    Picasso.with(mContext)
            .load(data.getThumbnailUrl())
            .transform(new RoundedTransformation(10, 10))
            .fit()
            .centerCrop()
            .into(thumb);

    thumb.setAdjustViewBounds(true);

    title.setText(data.getTitle().trim());
    description.setText(data.getDescription().trim());
    link.setText(data.getLink().trim());

    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (validated(activity, title, description, link)) {

                String titleText = title.getText().toString().trim();
                String descriptionText = description.getText().toString().trim();
                String linkText = link.getText().toString().trim();

                setEmptyView(activity);

                if (linkText.equals(data.getLink())) {
                    data.setTitle(titleText);
                    data.setDescription(descriptionText);
                    adapter.notifyDataSetChanged();

                } else {
                    String convertedLink = convertLink(linkText);

                    if (NetworkUtils.isNetworkAvailable(mContext)) {
                        progress = new ProgressDialog(activity);
                        progress.setCancelable(false);
                        progress.show();
                        new VideoInfoTask().execute(convertedLink, linkText, String.valueOf(position));
                    } else {
                        Toast.makeText(mContext, R.string.network_error, Toast.LENGTH_SHORT).show();
                    }
                }

                dialog.dismiss();
            }

        }
    });
}
 
Example 15
Source File: UpdateableAppsHeader.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
public Delegate(Activity activity) {
    inflater = activity.getLayoutInflater();
}
 
Example 16
Source File: MainActivity.java    From music_player with Open Software License 3.0 4 votes vote down vote up
private void showMusicInfo(final Activity context, final int position) {
    LayoutInflater inflater = context.getLayoutInflater();
    final View musicinfo_dialog = inflater.inflate(R.layout.musicinfo_dialog, (ViewGroup) context.findViewById(R.id.musicInfo_dialog));
    final EditText title = (EditText) musicinfo_dialog.findViewById(R.id.dialog_title);
    final EditText artist = (EditText) musicinfo_dialog.findViewById(R.id.dialog_artist);
    final EditText album = (EditText) musicinfo_dialog.findViewById(R.id.dialog_album);
    TextView duration = (TextView) musicinfo_dialog.findViewById(R.id.dialog_duration);
    TextView playtimes = (TextView) musicinfo_dialog.findViewById(R.id.dialog_playtimes);
    TextView path = (TextView) musicinfo_dialog.findViewById(R.id.dialog_path);
    final musicInfo nowMusic = MyApplication.getMusicListNow().get(position);
    title.setText(nowMusic.getMusicTitle());
    artist.setText(nowMusic.getMusicArtist());
    album.setText(nowMusic.getMusicAlbum());
    int totalSecond = nowMusic.getMusicDuration() / 1000;
    int minute = totalSecond / 60;
    int second = totalSecond - minute * 60;
    duration.setText(String.valueOf(minute) + "分" + String.valueOf(second) + "秒");
    playtimes.setText(String.valueOf(nowMusic.getTimes()));
    path.setText(nowMusic.getMusicData());
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("歌曲信息");
    builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            nowMusic.setmTitle(title.getText().toString());
            nowMusic.setmArtist(artist.getText().toString());
            nowMusic.setmAlbum(album.getText().toString());
            MyApplication.getBoxStore().boxFor(musicInfo.class).put(nowMusic);
            //更新界面
            ChangeScrollingUpPanel(MyApplication.getPositionNow());
            //通知其他adapter
            MyApplication.reDisplay(context);
        }
    });
    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

        }
    });
    builder.setView(musicinfo_dialog);
    builder.show();
}
 
Example 17
Source File: InfoTemplate.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void editItem(final Activity activity, int position) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.info_dialog_add_edit_data, null);
    final AlertDialog dialog = new AlertDialog.Builder(activity)
            .setTitle(R.string.info_edit_title)
            .setView(dialogView,
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_left),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_top),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_right),
                    activity.getResources().getDimensionPixelSize(R.dimen.spacing_bottom))
            .setPositiveButton(R.string.info_template_ok, null)
            .setNegativeButton(R.string.info_template_cancel, null)
            .create();
    dialog.show();

    final InfoModel data = infoData.get(position);

    final EditText word = (EditText) dialogView.findViewById(R.id.info_word);
    final EditText meaning = (EditText) dialogView.findViewById(R.id.info_meaning);
    word.setText(data.getInfoObject().trim());
    meaning.setText(data.getInfoDescription().trim());

    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (validated(activity, word, meaning)) {
                String wordText = word.getText().toString().trim();
                String meaningText = meaning.getText().toString().trim();

                data.setWord(wordText);
                data.setInfoDescription(meaningText);

                adapter.notifyDataSetChanged();
                dialog.dismiss();
            }

        }
    });
}
 
Example 18
Source File: MessageAdapter.java    From twiliochat-android with MIT License 4 votes vote down vote up
public MessageAdapter(Activity activity) {
  layoutInflater = activity.getLayoutInflater();
  messages = new ArrayList<>();
}
 
Example 19
Source File: NodeInfoListAdapter.java    From android-wallet-app with GNU General Public License v3.0 4 votes vote down vote up
public NodeInfoListAdapter(Activity context, int resource, List<NodeInfo> items) {
    super(context, resource, items);
    inflator = context.getLayoutInflater();
}
 
Example 20
Source File: RemovePreferenceHeaderDialogBuilder.java    From AndroidPreferenceActivity with Apache License 2.0 3 votes vote down vote up
/**
 * Inflates the layout of the dialog.
 *
 * @param activity
 *         The activity, the dialog should belong to, as an instance of the class {@link
 *         Activity}
 * @return The view, which has been inflated, as an instance of the class {@link View}
 */
@SuppressLint("InflateParams")
private View inflateLayout(final Activity activity) {
    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.remove_preference_header_dialog, null);
    setView(view);
    return view;
}