Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:com.android.calendar.selectcalendars.SelectSyncedCalendarsMultiAccountAdapter.java

public SelectSyncedCalendarsMultiAccountAdapter(Context context, Cursor acctsCursor,
        SelectSyncedCalendarsMultiAccountActivity act) {
    super(acctsCursor, context);
    mSyncedText = context.getString(R.string.synced);
    mNotSyncedText = context.getString(R.string.not_synced);

    mCache = new CalendarColorCache(context, this);

    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mResolver = context.getContentResolver();
    mActivity = act;//from   w  w w. j av  a 2  s .  c om
    mFragmentManager = act.getSupportFragmentManager();
    mColorPickerDialog = (CalendarColorPickerDialog) mFragmentManager
            .findFragmentByTag(COLOR_PICKER_DIALOG_TAG);
    mIsTablet = Utils.getConfigBool(context, R.bool.tablet_config);

    if (mCalendarsUpdater == null) {
        mCalendarsUpdater = new AsyncCalendarsUpdater(mResolver);
    }

    if (acctsCursor == null || acctsCursor.getCount() == 0) {
        Log.i(TAG, "SelectCalendarsAdapter: No accounts were returned!");
    }
    // Collect proper description for account types
    mAuthDescs = AccountManager.get(context).getAuthenticatorTypes();
    for (int i = 0; i < mAuthDescs.length; i++) {
        mTypeToAuthDescription.put(mAuthDescs[i].type, mAuthDescs[i]);
    }
    mView = mActivity.getExpandableListView();
    mRefresh = true;
    mClosedCursorsFlag = false;

    mColorViewTouchAreaIncrease = context.getResources()
            .getDimensionPixelSize(R.dimen.color_view_touch_area_increase);
}

From source file:com.juick.android.MessagesFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    LayoutInflater li = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    viewLoading = li.inflate(R.layout.listitem_loading, null);
    if (!messagesSource.canNext()) {
        viewLoading.findViewById(R.id.loadingg).setVisibility(View.GONE);
        viewLoading.findViewById(R.id.end_of_messages).setVisibility(View.VISIBLE);
        viewLoading.findViewById(R.id.progress_bar).setVisibility(View.GONE);
        viewLoading.findViewById(R.id.progress_loading_more).setVisibility(View.GONE);
    }/*from   w w  w  .j  av  a  2s  .c  om*/

    mRefreshView = (RelativeLayout) li.inflate(R.layout.pull_to_refresh_header, null);
    mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
    mRefreshViewImage = (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
    mRefreshViewProgress = (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
    mRefreshViewImage.setMinimumHeight(50);
    mRefreshView.setOnClickListener(this);
    mRefreshOriginalTopPadding = mRefreshView.getPaddingTop();
    mRefreshState = TAP_TO_REFRESH;

    final ListView listView = getListView();
    listView.setBackgroundDrawable(null);
    listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    installDividerColor(listView);
    MainActivity.restyleChildrenOrWidget(listView);

    listAdapter = new JuickMessagesAdapter(getActivity(), this, JuickMessagesAdapter.TYPE_MESSAGES,
            allMessages ? JuickMessagesAdapter.SUBTYPE_ALL : JuickMessagesAdapter.SUBTYPE_OTHER);

    listAdapter.setOnForgetListener(new Utils.Function<Void, JuickMessage>() {
        @Override
        public Void apply(final JuickMessage jm) {
            Network.executeJAHTTPS(
                    getActivity(), null, JA_API_URL + "/pending?command=ignore&mid="
                            + ((JuickMessageID) jm.getMID()).getMid() + "&rid=" + jm.getRID(),
                    new Utils.Function<Void, RESTResponse>() {
                        @Override
                        public Void apply(final RESTResponse response) {
                            final Activity activity = getActivity();
                            if (activity == null)
                                return null; // gone.
                            if (response.getErrorText() != null) {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        Toast.makeText(activity, response.getErrorText(), Toast.LENGTH_SHORT)
                                                .show();
                                    }
                                });
                            } else {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        listAdapter.remove(jm);
                                        //To change body of implemented methods use File | Settings | File Templates.
                                        if (listAdapter.getCount() == 0) {
                                            if ((activity instanceof MainActivity)) {
                                                ((MainActivity) activity).doReload();
                                            }
                                        }
                                    }
                                });
                            }
                            return null;
                        }
                    });
            return null;
        }
    });
    listView.setOnTouchListener(this);
    listView.setOnScrollListener(this);
    listView.setOnItemClickListener(this);

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            if (view instanceof ImageGallery) {
                return false; // no need that! (possibly, make this condition work only if not scrolled meanwhile)
            }
            final Object itemAtPosition = parent.getItemAtPosition(position);
            if (itemAtPosition instanceof JuickMessage) {
                doOnClickActualTime = System.currentTimeMillis();
                doOnClick = new Runnable() {
                    @Override
                    public void run() {
                        JuickMessage msg = (JuickMessage) itemAtPosition;
                        MessageMenu messageMenu = MainActivity.getMicroBlog(msg).getMessageMenu(getActivity(),
                                messagesSource, listView, listAdapter);
                        if (messageMenu != null) {
                            messageMenu.onItemLongClick(parent, view, position, id);
                        } else {
                            Toast.makeText(getActivity(), "Not implemented ;-(", Toast.LENGTH_LONG).show();
                        }
                    }
                };
                if (alternativeLongClick) {
                    listView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
                } else {
                    doOnClick.run();
                    doOnClick = null;
                    return true;
                }
            }
            return false;
        }
    });
    listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            System.out.println();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            System.out.println();
        }
    });
    init(false);
    if (parent != null) {
        parent.onFragmentCreated();
    }
}

From source file:com.irccloud.android.activity.BaseActivity.java

public View getDialogTextPrompt() {
    if (dialogTextPrompt == null)
        dialogTextPrompt = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.dialog_textprompt, null);
    if (dialogTextPrompt.getParent() != null)
        ((ViewGroup) dialogTextPrompt.getParent()).removeView(dialogTextPrompt);
    return dialogTextPrompt;
}

From source file:com.afrozaar.jazzfestreporting.MainActivity.java

/**
 * This method renders the ListView explaining what the configurations the
 * developer of this application has to complete. Typically, these are
 * static variables defined in {@link Auth} and {@link Constants}.
 *//*from w  w w  .  j a va 2s .  c  o m*/
private void showMissingConfigurations() {
    List<MissingConfig> missingConfigs = new ArrayList<MissingConfig>();

    // Make sure an API key is registered
    if (Auth.KEY.startsWith("Replace")) {
        missingConfigs.add(new MissingConfig("API key not configured",
                "KEY constant in Auth.java must be configured with your Simple API key from the Google API Console"));
    }

    // Make sure a playlist ID is registered
    if (Constants.UPLOAD_PLAYLIST.startsWith("Replace")) {
        missingConfigs.add(new MissingConfig("Playlist ID not configured",
                "UPLOAD_PLAYLIST constant in Constants.java must be configured with a Playlist ID to submit to. (The playlist ID typically has a prexix of PL)"));
    }

    // Renders a simple_list_item_2, which consists of a title and a body
    // element
    ListAdapter adapter = new ArrayAdapter<MissingConfig>(this, android.R.layout.simple_list_item_2,
            missingConfigs) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row;
            if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) getApplicationContext()
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = convertView;
            }

            TextView titleView = (TextView) row.findViewById(android.R.id.text1);
            TextView bodyView = (TextView) row.findViewById(android.R.id.text2);
            MissingConfig config = getItem(position);
            titleView.setText(config.title);
            bodyView.setText(config.body);
            return row;
        }
    };

    // Wire the data adapter up to the view
    ListView missingConfigList = (ListView) findViewById(R.id.missing_config_list);
    missingConfigList.setAdapter(adapter);
}

From source file:com.arctech.stikyhive.ChattingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    recipientStkid = getIntent().getExtras().getString("recipientStkid");
    chatRecipient = getIntent().getExtras().getString("chatRecipient");
    chatRecipientUrl = getIntent().getExtras().getString("chatRecipientUrl");
    senderToken = getIntent().getExtras().getString("senderToken");
    recipientToken = getIntent().getExtras().getString("recipientToken");
    noti = getIntent().getExtras().getBoolean("noti");
    message = getIntent().getExtras().getString("message");
    rows = getIntent().getExtras().getInt("rows");

    pref = PreferenceManager.getDefaultSharedPreferences(this);
    ws = new JsonWebService();
    dbHelper = new DBHelper(this);
    dialog = new ProgressDialog(this);
    listChatContact = new ArrayList<>();
    listChatContact = dbHelper.getChatContact();
    Log.i(" Chat Contact ", " " + listChatContact.size());
    //to change font
    faceSemi_bold = Typeface.createFromAsset(getAssets(), fontOSSemi_bold);
    Typeface faceLight = Typeface.createFromAsset(getAssets(), fontOSLight);
    faceRegular = Typeface.createFromAsset(getAssets(), fontOSRegular);

    imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited()) {
        imageLoader.init(ImageLoaderConfiguration.createDefault(this));
    }//from ww  w .  j  a  v a 2 s  .  c  o m

    start = new Date();
    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
    timeSend = oFormat.format(start);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.chat);

    txtUserName = (TextView) findViewById(R.id.txtChatName);
    edTxtMsg = (EditText) findViewById(R.id.edTxtMsg);
    imgViewProfile = (ImageView) findViewById(R.id.imgViewChat);
    imgViewAddCon = (ImageView) findViewById(R.id.imgAddContact);
    lv = (ListView) findViewById(R.id.listView1);
    layoutLabel = (LinearLayout) findViewById(R.id.layoutLabel);
    txtLabel1 = (TextView) findViewById(R.id.txtLabel1);
    txtLabel2 = (TextView) findViewById(R.id.txtLabel2);
    txtLabel3 = (TextView) findViewById(R.id.txtLabel3);
    txtLabel2.setText(" " + chatRecipient + " ");
    txtLabel1.setTypeface(faceLight);
    txtLabel2.setTypeface(faceRegular);
    txtLabel3.setTypeface(faceLight);
    // lv.smoothScrollToPosition(adapter.getCount() - 1);

    for (ChatContact contact : listChatContact) {
        if (contact.getContactId().equals(recipientStkid)) {
            imgViewAddCon.setVisibility(View.INVISIBLE);
            layoutLabel.setVisibility(View.GONE);
            break;
        }
    }
    Log.i(TAG, " come back again");
    adapter = new ChatArrayAdapter(getApplicationContext(), R.layout.messaging_listview, faceSemi_bold,
            faceRegular);
    lv.setAdapter(adapter);
    // adapter.add(new StikyChat(chatRecipientUrl, "Hello", false, "12.10.2015", "12.1.2014"));

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    // BEGIN_INCLUDE (change_colors)
    // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
    swipeRefreshLayout.setColorScheme(R.color.swipe_color_1, R.color.swipe_color_2, R.color.swipe_color_3,
            R.color.swipe_color_4);
    limitMsg = 7;
    // END_INCLUDE (change_colors)
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.i(" Refresh Layout ", "onRefresh called from SwipeRefreshLayout");
            if (limitMsg < rows) {
                Log.i("Limit Message ", " " + limitMsg);
                limitMsg *= 2;
                fetchRecords();
            } else if (limitMsg > rows && (limitMsg - rows < 7)) {
                fetchRecords();
            } else {
                Log.i("No data ", "to refresh");
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(getApplicationContext(), "No data to refresh!", Toast.LENGTH_SHORT).show();
            }

            // initiateRefresh();
        }
    });

    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout headerLayout = (LinearLayout) findViewById(R.id.header);
    View header = inflator.inflate(R.layout.header, null);

    TextView textView = (TextView) header.findViewById(R.id.textView1);
    textView.setText("StikyChat");
    textView.setTypeface(faceSemi_bold);
    textView.setVisibility(View.VISIBLE);
    headerLayout.addView(header);
    LinearLayout layoutRight = (LinearLayout) header.findViewById(R.id.layoutRight);
    layoutRight.setVisibility(View.GONE);

    txtUserName.setText(chatRecipient);
    Log.i(TAG, "Activity Name " + txtUserName.getText().toString());
    txtUserName.setTypeface(faceSemi_bold);

    String url = "";
    if (chatRecipientUrl.contains("http")) {
        url = chatRecipientUrl;
    } else {
        url = this.getResources().getString(R.string.url) + "/" + chatRecipientUrl;
    }
    addAndroidUniversalImageLoader(imgViewProfile, url);
    //        if (noti && (!message.equals(""))) {
    //            adapter.add(new StikyChat(chatRecipientUrl, message, true, timeSend, ""));
    //            lv.smoothScrollToPosition(adapter.getCount() - 1);
    //        }

    //to show history chats between two users(sender & recipient)
    dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dateFormat2 = new SimpleDateFormat("dd MMM HH:mm");
    listHistory = dbHelper.getStikyChat();
    if (listHistory.size() > 0) {
        Collections.reverse(listHistory);
        for (StikyChatTb chatTb : listHistory) {
            String getDate = chatTb.getSendDate();
            String fromStikyBee = chatTb.getSender();
            try {
                String createDate = dateFormat2.format(dateFormat.parse(getDate));
                if (fromStikyBee.equals(pref.getString("stkid", ""))) {
                    adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, ""));
                } else {
                    adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, ""));
                }
                lv.smoothScrollToPosition(adapter.getCount() - 1);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            messageGCM = sharedPreferences.getString("message", "");
            recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", "");
            recipientNameGCM = sharedPreferences.getString("chatRecipientName", "");
            recipientStkidGCM = sharedPreferences.getString("recipientStkid", "");
            recipientTokenGCM = sharedPreferences.getString("recipientToken", "");
            senderTokenGCM = sharedPreferences.getString("senderToken", "");

            Log.i(TAG, "..." + recipientStkidGCM.trim() + " STKID " + recipientStkid.trim() + ":");
            if (firstConnect) {
                if (recipientStkidGCM.trim() == recipientStkid.trim()
                        || recipientStkidGCM.equals(recipientStkid)) {
                    MyGcmListenerService.flagSendNoti = false;
                    Log.i(TAG, " " + message);
                    // (1) get today's date
                    start = new Date();
                    SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm");
                    timeSend = oFormat.format(start);

                    Log.i(TAG, "First connect " + firstConnect);
                    StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, "");
                    Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend);
                    Log.i(TAG, "User " + txtUserName.getText().toString());
                    //txtUserName.setText(message);
                    Log.i(TAG, "User 2 " + txtUserName.getText().toString());
                    adapter.add(stikyChat);
                    adapter.notifyDataSetChanged();
                    //new regTask2().execute("Obj ");
                    lv.smoothScrollToPosition(adapter.getCount() - 1);
                } else {
                    Log.i(TAG, "..." + recipientStkidGCM.trim());
                    Log.i(TAG, "&&&" + recipientStkid.trim());
                    Log.i(TAG, "else casee");
                    //notificaton send
                    flagNotifi = true;
                    new regTask2().execute("Notification");
                }
                firstConnect = false;
            }
        }
    };
}

From source file:com.github.riotopsys.shoppinglist.activity.ShoppingListPreview.java

private void renameList() {

    ShoppingList list;//from   www.  java 2 s  .c  o  m
    if (mShoppingListCollectionAdapter.getCount() == 0) {
        return;
    }
    list = mShoppingListCollectionAdapter.getList(mViewPager.getCurrentItem());

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.add_list_dialog, null);
    ((TextView) view.findViewById(R.id.list_name)).setText(list.getName());

    new AlertDialog.Builder(this).setTitle(R.string.add_list_dialog_title).setView(view)
            .setPositiveButton(R.string.done, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    EditText editText = (EditText) ((AlertDialog) dialog).findViewById(R.id.list_name);
                    String text = editText.getText().toString();

                    if (!text.equals("")) {
                        ShoppingList shoppingList = mShoppingListCollectionAdapter
                                .getList(mViewPager.getCurrentItem());
                        shoppingList.setName(ShoppingListPreview.this, text);
                        mShoppingListCollectionAdapter.notifyDataSetChanged(editText.getContext());
                    } else {
                        Toast.makeText(getBaseContext(), R.string.name_reqd, Toast.LENGTH_LONG).show();
                    }
                }
            }).setNegativeButton(R.string.cancel, new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create().show();
}

From source file:com.pixplicity.castdemo.MainActivity.java

private void updateMessages() {
    if (mMessageListMessages.size() > 0) {
        mVgLogo.setVisibility(View.INVISIBLE);
    }/*from   w  ww. j a va 2 s  . c  om*/
    if (mMessageAdapter == null) {
        mMessageAdapter = new BaseAdapter() {

            @SuppressLint("InflateParams")
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View row;
                if (convertView == null) {
                    LayoutInflater inflater = (LayoutInflater) getApplicationContext()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    row = inflater.inflate(R.layout.list_messages, null);
                } else {
                    row = convertView;
                }
                /* TODO
                Message msg = getItem(position);
                row.getText1().setText(msg.username);
                row.getText2().setText(msg.message);
                */
                ((TextView) row.findViewById(R.id.tv_username)).setText(mMessageListUsernames.get(position));
                ((TextView) row.findViewById(R.id.tv_message)).setText(mMessageListMessages.get(position));
                return row;
            }

            @Override
            public int getCount() {
                return mMessageListMessages.size();
            }

            @Override
            public Message getItem(int position) {
                // TODO return mMessageList.get(position);
                return null;
            }

            @Override
            public long getItemId(int position) {
                return 0;
            }
        };
        mLvMessages.setAdapter(mMessageAdapter);
    }
}

From source file:com.mk27manoj.crewtools.fragments.CreateViewCompanyFragment.java

private void addService(String name) {
    LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View baseView = layoutInflater.inflate(R.layout.row_create_company_add_service, null);
    TextView txtService = (TextView) baseView.findViewById(R.id.textview_create_company_add_service_name);
    ImageView imgRemove = (ImageView) baseView.findViewById(R.id.imageview_create_company_add_service_remove);
    baseView.setTag(serviceContainer.getChildCount());
    imgRemove.setTag(serviceContainer.getChildCount());

    txtService.setText(name);//ww  w . ja v a2  s . com
    imgRemove.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((LinearLayout) baseView.getParent()).removeView(baseView);
            services.remove(serviceContainer.indexOfChild(v));
            mCompany.setServiceTypes(services);
        }
    });
    serviceContainer.addView(baseView);
}

From source file:com.achep.acdisplay.ui.widgets.notification.NotificationActions.java

/**
 * Sets new actions.//from   www.j  a  v  a  2s. c om
 *
 * @param notification the host notification
 * @param actions      the actions to set
 */
public void setActions(@Nullable OpenNotification notification, @Nullable Action[] actions) {
    Check.getInstance().isInMainThread();

    mRemoteInputsMap.clear();
    mActionsMap.clear();
    hideRii();

    if (actions == null) {
        // Free actions' container.
        removeAllViews();
        return;
    } else {
        assert notification != null;
    }

    int count = actions.length;
    View[] views = new View[count];

    // Find available views.
    int childCount = getChildCount();
    int a = Math.min(childCount, count);
    for (int i = 0; i < a; i++) {
        views[i] = getChildAt(i);
    }

    // Remove redundant views.
    for (int i = childCount - 1; i >= count; i--) {
        removeViewAt(i);
    }

    LayoutInflater inflater = null;
    for (int i = 0; i < count; i++) {
        final Action action = actions[i];
        View root = views[i];

        if (root == null) {
            // Initialize layout inflater only when we really need it.
            if (inflater == null) {
                inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                assert inflater != null;
            }

            root = inflater.inflate(getActionLayoutResource(), this, false);
            root = onCreateActionView(root);
            // We need to keep all IDs unique to make
            // TransitionManager.beginDelayedTransition(viewGroup, null)
            // work correctly!
            root.setId(getChildCount() + 1);
            addView(root);
        }

        mActionsMap.put(root, action);

        int style = Typeface.NORMAL;
        root.setOnLongClickListener(null);
        if (action.intent != null) {
            root.setEnabled(true);
            root.setOnClickListener(mActionsOnClick);

            RemoteInput remoteInput = getRemoteInput(action);
            if (remoteInput != null) {
                mRemoteInputsMap.put(action, remoteInput);
                root.setOnLongClickListener(mActionsOnLongClick);

                // Highlight the action
                style = Typeface.ITALIC;
            }
        } else {
            root.setEnabled(false);
            root.setOnClickListener(null);
        }

        // Get message view and apply the content.
        TextView textView = root instanceof TextView ? (TextView) root
                : (TextView) root.findViewById(android.R.id.title);
        textView.setText(action.title);
        if (mTypeface == null)
            mTypeface = textView.getTypeface();
        textView.setTypeface(mTypeface, style);

        Drawable icon = NotificationUtils.getDrawable(getContext(), notification, action.icon);
        if (icon != null)
            icon = onCreateActionIcon(icon);

        if (Device.hasJellyBeanMR1Api()) {
            textView.setCompoundDrawablesRelative(icon, null, null, null);
        } else {
            textView.setCompoundDrawables(icon, null, null, null);
        }
    }
}

From source file:com.insthub.O2OMobile.Activity.C17_ApplyFormActivity.java

/**
 * popwindow//from w  w  w. j a  v a 2s  . c om
 *
 * @param parent
 */
private void showPopWindow(View parent) {
    int id = parent.getId();
    switch (id) {
    case R.id.service_type:
        if (mServiceListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mServicePopwindowView = layoutInflater.inflate(R.layout.service_type_popwindow, null);
            mServicePopwindowListView = (ListView) mServicePopwindowView
                    .findViewById(R.id.service_type_pop_listview);
            mServiceListPopwindow = new PopupWindow(mServicePopwindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mServiceTypePopAdapter == null) {
            mServiceTypePopAdapter = new ServiceTypePopAdapter(this, mServiceModel.publicServiceTypeList);
            mServicePopwindowListView.setAdapter(mServiceTypePopAdapter);
        }
        mServiceListPopwindow.setFocusable(true);
        // ?
        mServiceListPopwindow.setOutsideTouchable(true);
        mServiceTypeArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mServiceListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mServiceListPopwindow.showAsDropDown(parent);
        mServiceListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mServiceTypeArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mServicePopwindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_TYPE serviceType = mServiceTypeList.get(position);
                mServiceTypeId = serviceType.id;
                mServiceTypeTitle.setText(serviceType.title);
                mServiceModel.publicIsSecondCategory = false;
                mServiceModel.getCategoryList(mServiceTypeId);
                mServiceListPopwindow.dismiss();
            }
        });
        break;
    case R.id.first_category:
        if (mFirstCategoryListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mFirstCategoryPopWindowView = layoutInflater.inflate(R.layout.first_category_popwindow, null);
            mFirstCategoryPopWindowListView = (ListView) mFirstCategoryPopWindowView
                    .findViewById(R.id.first_category_pop_listview);
            mFirstCategoryListPopwindow = new PopupWindow(mFirstCategoryPopWindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mFirstCategoryPopAdapter == null) {
            mFirstCategoryPopAdapter = new FirstCategoryPopAdapter(this, mFirstCategoryList);
            mFirstCategoryPopWindowListView.setAdapter(mFirstCategoryPopAdapter);
        } else {
            mFirstCategoryPopAdapter.publicFirstCategoryList = mFirstCategoryList;
            mFirstCategoryPopAdapter.notifyDataSetChanged();
        }
        mFirstCategoryListPopwindow.setFocusable(true);
        // ?
        mFirstCategoryListPopwindow.setOutsideTouchable(true);
        mFirstCategoryArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mFirstCategoryListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mFirstCategoryListPopwindow.showAsDropDown(parent);
        mFirstCategoryListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mFirstCategoryArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mFirstCategoryPopWindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_CATEGORY service_category = mFirstCategoryList.get(position);
                mFirstClassServiceCategory = service_category.id;
                mFirstCategoryTitle.setText(service_category.title);
                mServiceModel.publicIsSecondCategory = true;
                mServiceModel.getCategoryList(mFirstClassServiceCategory);
                mFirstCategoryListPopwindow.dismiss();
            }
        });
        break;
    case R.id.second_category:
        if (mSecondCategoryListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mSecondCategoryPopWindowView = layoutInflater.inflate(R.layout.second_category_popwindow, null);
            mSecondCategoryPopWindowListView = (ListView) mSecondCategoryPopWindowView
                    .findViewById(R.id.second_category_pop_listview);
            mSecondCategoryListPopwindow = new PopupWindow(mSecondCategoryPopWindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mSecondCategoryPopAdapter == null) {
            mSecondCategoryPopAdapter = new SecondCategoryPopAdapter(this, mSecondCategoryList);
            mSecondCategoryPopWindowListView.setAdapter(mSecondCategoryPopAdapter);
        } else {
            mSecondCategoryPopAdapter.publicSecondCategoryList = mSecondCategoryList;
            mSecondCategoryPopAdapter.notifyDataSetChanged();
        }

        mSecondCategoryListPopwindow.setFocusable(true);
        // ?
        mSecondCategoryListPopwindow.setOutsideTouchable(true);
        mSecondCategoryArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mSecondCategoryListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mSecondCategoryListPopwindow.showAsDropDown(parent);
        mSecondCategoryListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mSecondCategoryArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mSecondCategoryPopWindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_CATEGORY service_category = mSecondCategoryList.get(position);
                mSecondVlassServiceCategory = service_category.id;
                mSecondCategoryTitle.setText(service_category.title);
                mServiceModel.publicIsSecondCategory = true;
                mSecondCategoryListPopwindow.dismiss();
            }
        });
        break;
    }

}