Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

In this page you can find the example usage for android.widget ImageView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:org.runbuddy.tomahawk.ui.fragments.ChartsSelectorFragment.java

private void setSelectorHeaderMode(boolean selectorShown) {
    if (getView() != null) {
        ImageView arrowTop = (ImageView) getView().findViewById(R.id.arrow_top_header);
        ImageView arrowBottom = (ImageView) getView().findViewById(R.id.arrow_bottom_header);
        View selectorHeader = getView().findViewById(R.id.selectorHeader);
        TextView textViewHeader = (TextView) getView().findViewById(R.id.textview_header);

        selectorHeader.setClickable(!selectorShown);
        arrowTop.setVisibility(selectorShown ? View.GONE : View.VISIBLE);
        arrowBottom.setVisibility(selectorShown ? View.GONE : View.VISIBLE);
        textViewHeader.setVisibility(selectorShown ? View.VISIBLE : View.GONE);
    }/*from  w ww .j  av  a2  s. c o  m*/
}

From source file:org.mercycorps.translationcards.activity.RecordingActivity.java

private void moveToLabelStep() {
    setContentView(R.layout.recording_label);
    TextView labelTitle = (TextView) findViewById(R.id.recording_label_title);
    labelTitle.setText(getString(R.string.recording_label_create_title, dictionaryLabel));
    recycleBitmap();//from  w ww. jav a  2 s  .  c om
    currentBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.recording_label_image);
    currentBitmapView = (ImageView) findViewById(R.id.recording_label_image);
    currentBitmapView.setImageBitmap(currentBitmap);
    final EditText labelField = (EditText) findViewById(R.id.recording_label_field);
    final EditText translatedTextField = (EditText) findViewById(R.id.recording_translated_text_field);
    fillPrepopulatedField(label, labelField, getString(R.string.recording_label_hint_text));
    fillPrepopulatedField(translatedText, translatedTextField,
            String.format(getString(R.string.translated_text_hint), dictionaryLabel));
    if (inEditMode) {
        ImageView deleteButton = (ImageView) findViewById(R.id.recording_label_delete_image);
        deleteButton.setVisibility(View.VISIBLE);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DbManager dbm = new DbManager(RecordingActivity.this);
                dbm.deleteTranslation(translationId);
                if (!isAsset) {
                    File oldFile = new File(filename);
                    oldFile.delete();
                    if (!savedIsAsset && (savedFilename != null) && !savedFilename.equals(filename)) {
                        oldFile = new File(savedFilename);
                        oldFile.delete();
                    }
                }
                setResult(RESULT_OK, intent);
                finish();
            }
        });
        findViewById(R.id.recording_label_step_marker).setVisibility(View.GONE);
    }
    labelField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            setFieldBasedOnFocus(hasFocus, labelField, R.string.recording_label_hint_text);
        }
    });

    translatedTextField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            setFieldBasedOnFocus(hasFocus, translatedTextField, R.string.recording_text_hint_text);
        }
    });

    labelField.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Do nothing here.
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() != 0 && !s.equals(getString(R.string.recording_label_hint_text))) {
                setLabelNextButtonEnabled(true);
            } else {
                setLabelNextButtonEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
            // Do nothing here.
        }
    });
    View nextButton = (View) findViewById(R.id.recording_label_next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            label = labelField.getText().toString();
            if (label.length() == 0 || label.equals(getString(R.string.recording_label_hint_text))) {
                return;
            }

            translatedText = translatedTextField.getText().toString();
            if (translatedText.trim().isEmpty()
                    || translatedText.equals(getString(R.string.recording_text_hint_text))) {
                translatedText = "";
            }
            moveToAudioStep();
        }
    });
    stepHistory.push(Step.LABEL);
}

From source file:com.asksven.betterbatterystats.adapters.StatsAdapter.java

public View getView(int position, View convertView, ViewGroup viewGroup) {
    StatElement entry = m_listData.get(position);

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.m_context);
    boolean bShowBars = sharedPrefs.getBoolean("show_gauge", false);

    if (LogSettings.DEBUG) {
        Log.i(TAG, "Values: " + entry.getVals());
    }/*from  ww  w  .  j av a  2 s  .c om*/

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) m_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        // depending on settings show new pie gauge or old bar gauge
        if (!bShowBars) {
            convertView = inflater.inflate(R.layout.stat_row, null);
        } else {
            convertView = inflater.inflate(R.layout.stat_row_gauge, null);
        }
    }

    final float scale = this.m_context.getResources().getDisplayMetrics().density;

    TextView tvName = (TextView) convertView.findViewById(R.id.TextViewName);

    /////////////////////////////////////////
    // we do some stuff here to handle settings about font size and thumbnail size
    String fontSize = sharedPrefs.getString("medium_font_size", "16");
    int mediumFontSize = Integer.parseInt(fontSize);

    //we need to change "since" fontsize
    tvName.setTextSize(TypedValue.COMPLEX_UNIT_SP, mediumFontSize);

    // We need to handle an exception here: Sensors do not have a name so we use the fqn instead
    if (entry instanceof SensorUsage) {
        tvName.setText(entry.getFqn(UidNameResolver.getInstance(m_context)));

    } else {
        tvName.setText(entry.getName());
    }

    boolean bShowKb = sharedPrefs.getBoolean("enable_kb", true);
    ImageView iconKb = (ImageView) convertView.findViewById(R.id.imageKB);

    iconKb.setVisibility(View.INVISIBLE);

    TextView tvFqn = (TextView) convertView.findViewById(R.id.TextViewFqn);
    tvFqn.setText(entry.getFqn(UidNameResolver.getInstance(m_context)));

    TextView tvData = (TextView) convertView.findViewById(R.id.TextViewData);

    // for alarms the values is wakeups per hour so we need to take the time as reference for the text
    if (entry instanceof Alarm) {
        tvData.setText(entry.getData((long) m_timeSince));
    } else {
        tvData.setText(entry.getData((long) m_maxValue));
    }

    //LinearLayout myLayout = (LinearLayout) convertView.findViewById(R.id.LinearLayoutBar);
    LinearLayout myFqnLayout = (LinearLayout) convertView.findViewById(R.id.LinearLayoutFqn);
    LinearLayout myRow = (LinearLayout) convertView.findViewById(R.id.LinearLayoutEntry);

    // long press for "copy to clipboard"
    convertView.setOnLongClickListener(new OnItemLongClickListener(position));

    if (!bShowBars) {
        GraphablePie gauge = (GraphablePie) convertView.findViewById(R.id.Gauge);

        /////////////////////////////////////////
        // we do some stuff here to handle settings about font size and thumbnail size
        String iconDim = sharedPrefs.getString("thumbnail_size", "56");
        int iconSize = Integer.parseInt(iconDim);
        int pixels = (int) (iconSize * scale + 0.5f);
        //we need to change "since" fontsize
        gauge.getLayoutParams().height = pixels;
        gauge.getLayoutParams().width = pixels;
        gauge.requestLayout();

        ////////////////////////////////////////////////////////////////////////////////////
        if (entry instanceof NetworkUsage) {
            gauge.setValue(entry.getValues()[0], ((NetworkUsage) entry).getTotal());

        } else {
            double max = m_maxValue;
            // avoid rounding errors leading to values > 100 %
            if (entry.getValues()[0] > max) {
                max = entry.getValues()[0];
                Log.i(TAG, "Upping gauge max to " + max);
            }
            gauge.setValue(entry.getValues()[0], max);
        }
    } else {
        GraphableBars buttonBar = (GraphableBars) convertView.findViewById(R.id.ButtonBar);
        int iHeight = 10;
        try {
            iHeight = Integer.valueOf(sharedPrefs.getString("graph_bar_height", "10"));
        } catch (Exception e) {
            iHeight = 10;
        }
        if (iHeight == 0) {
            iHeight = 10;
        }

        buttonBar.setMinimumHeight(iHeight);
        buttonBar.setName(entry.getName());
        buttonBar.setValues(entry.getValues(), m_maxValue);
    }
    ImageView iconView = (ImageView) convertView.findViewById(R.id.icon);
    LinearLayout iconLayout = (LinearLayout) convertView.findViewById(R.id.LayoutIcon);
    /////////////////////////////////////////
    // we do some stuff here to handle settings about font size and thumbnail size
    String iconDim = sharedPrefs.getString("thumbnail_size", "56");
    int iconSize = Integer.parseInt(iconDim);
    int pixels = (int) (iconSize * scale + 0.5f);
    //we need to change "since" fontsize
    iconView.getLayoutParams().width = pixels;
    iconView.getLayoutParams().height = pixels;
    iconView.requestLayout();
    //n 20;setLay.setTextSize(TypedValue.COMPLEX_UNIT_DIP, iconSize);

    ////////////////////////////////////////////////////////////////////////////////////

    // add on click listener for the icon only if KB is enabled
    //        if (bShowKb)
    //        {
    //           // set a click listener for the list
    //           iconKb.setOnClickListener(new OnIconClickListener(position));
    //        }

    // show / hide fqn text
    if ((entry instanceof Process) || (entry instanceof State) || (entry instanceof Misc)
            || (entry instanceof NativeKernelWakelock) || (entry instanceof Alarm)
            || (entry instanceof SensorUsage)) {
        myFqnLayout.setVisibility(View.GONE);
    } else {
        myFqnLayout.setVisibility(View.VISIBLE);
    }

    // show / hide package icons (we show / hide the whole layout as it contains a margin that must be hidded as well
    if ((entry instanceof NativeKernelWakelock) || (entry instanceof State) || (entry instanceof Misc)) {

        iconView.setVisibility(View.GONE);

    } else {
        iconView.setVisibility(View.VISIBLE);
        iconView.setImageDrawable(entry.getIcon(UidNameResolver.getInstance(m_context)));
        // set a click listener for the list
        iconView.setOnClickListener(new OnPackageClickListener(position));

    }

    // add on click listener for the list entry if details are availble
    if ((entry instanceof Alarm) || (entry instanceof NativeKernelWakelock) || (entry instanceof SensorUsage)) {
        convertView.setOnClickListener(new OnItemClickListener(position));
    }

    //        // show / hide set dividers
    //        ListView myList = (ListView) convertView.getListView(); //findViewById(R.id.id.list);
    //        myList.setDivider(new ColorDrawable(0x99F10529));
    //        myList.setDividerHeight(1);
    return convertView;
}

From source file:com.example.hifadhi.utils.CacheImageDownloader.java

/**
 * Same as {@link #download(String, ImageView)}, with the possibility to
 * provide an additional cookie that will be used when the image will be
 * retrieved.//from  www . j av  a 2 s  .c o  m
 * 
 * @param url
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 * @param cookie
 *            A cookie String that will be used by the http connection.
 */
public void download(final String url, final ImageView imageView, final String cookie) {
    resetPurgeTimer();
    final Bitmap bitmap = getBitmapFromCache(url);

    if (bitmap == null) {
        forceDownload(url, imageView, cookie);
    } else {
        CacheImageDownloader.cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
        imageView.setVisibility(View.VISIBLE);

    }
}

From source file:se.droidgiro.scanner.CaptureActivity.java

public void handleDecode(final Invoice invoice, int fieldsFound, Bitmap debugBmp) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    ImageView debugImageView = (ImageView) findViewById(R.id.debug_image_view);
    if (prefs.getBoolean(PreferencesActivity.KEY_DEBUG_IMAGE, false) && (debugBmp != null)) {
        debugImageView.setVisibility(View.VISIBLE);
        debugImageView.setImageBitmap(debugBmp);
    } else if (debugImageView.getVisibility() != View.GONE) {
        debugImageView.setVisibility(View.GONE);
    }/*  www  . jav  a 2s  . co  m*/
    int fieldsScanned = invoice.getLastFieldsDecoded();
    if (fieldsScanned > 0) {
        boolean scanContainsNewData = false;

        /*
         * The following segment will copy data from scanned invoice object
         * into our currentInvoice and keep track of new data read.
         * Beep/Vibrate will only occur if scan contains new data.
         */

        if ((fieldsScanned & Invoice.AMOUNT_FIELD) == Invoice.AMOUNT_FIELD) {
            if (!(currentInvoice.getAmount() == invoice.getAmount()
                    && currentInvoice.getAmountFractional() == invoice.getAmountFractional())) {
                currentInvoice.setAmount(invoice.getAmount(), invoice.getAmountFractional());
                scanContainsNewData = true;
            }
        }

        if ((fieldsScanned & Invoice.DOCUMENT_TYPE_FIELD) == Invoice.DOCUMENT_TYPE_FIELD) {
            if (currentInvoice.getInternalDocumentType() != invoice.getInternalDocumentType()) {
                currentInvoice.setDocumentType(invoice.getInternalDocumentType());
                scanContainsNewData = true;
            }
        }

        if ((fieldsScanned & Invoice.GIRO_ACCOUNT_FIELD) == Invoice.GIRO_ACCOUNT_FIELD) {
            Log.v(TAG, "Giro accout scanned. Current account = " + currentInvoice.getGiroAccount()
                    + ". New invoice giro account = " + invoice.getGiroAccount());
            if (!invoice.getGiroAccount().equals(currentInvoice.getGiroAccount())) {
                currentInvoice.setRawGiroAccount(invoice.getRawGiroAccount());
                Log.v(TAG, "Copied giro account = " + invoice.getGiroAccount());
                scanContainsNewData = true;
            }
        }

        if ((fieldsScanned & Invoice.REFERENCE_FIELD) == Invoice.REFERENCE_FIELD) {
            if (!invoice.getReference().equals(currentInvoice.getReference())) {
                currentInvoice.setReference(invoice.getReference());
                scanContainsNewData = true;
            }
        }

        if (scanContainsNewData)
            playBeepSoundAndVibrate();

    }
    Log.v(TAG, "CurrentInvoice = " + currentInvoice);
    if (currentInvoice.isReferenceDefined())
        resultListHandler.setReference(currentInvoice.getReference());
    if (currentInvoice.isAmountDefined())
        resultListHandler.setAmount(currentInvoice.getCompleteAmount());
    if (currentInvoice.isGiroAccountDefined())
        resultListHandler.setAccount(currentInvoice.getGiroAccount());
    if (resultListHandler.hasNewData()) {
        resultListHandler.setNewData(false);
    }

    Log.v(TAG, "Got invoice " + invoice);

    /* If scan on every hit */

    // int fieldsScanned = invoice.getLastFieldsDecoded();
    // if (fieldsScanned > 0) {
    // playBeepSoundAndVibrate();
    // final List<NameValuePair> params = new ArrayList<NameValuePair>();
    // if ((fieldsScanned & Invoice.AMOUNT_FIELD) == Invoice.AMOUNT_FIELD)
    // params.add(new BasicNameValuePair("amount", invoice
    // .getCompleteAmount()));
    // if ((fieldsScanned & Invoice.DOCUMENT_TYPE_FIELD) ==
    // Invoice.DOCUMENT_TYPE_FIELD)
    // params.add(new BasicNameValuePair("type", invoice.getType()));
    // if ((fieldsScanned & Invoice.GIRO_ACCOUNT_FIELD) ==
    // Invoice.GIRO_ACCOUNT_FIELD)
    // params.add(new BasicNameValuePair("account", invoice
    // .getGiroAccount()));
    // if ((fieldsScanned & Invoice.REFERENCE_FIELD) ==
    // Invoice.REFERENCE_FIELD)
    // params.add(new BasicNameValuePair("reference", invoice
    // .getReference()));
    // // sendFields(params);
    //
    // }

    // if (invoice.isComplete()) {
    // resultListHandler.setSent(true);
    // this.scanButton.setText(getString(R.string.scan_state_scan));
    // onContentChanged();
    // } else
    if (!paused) {
        handler.sendEmptyMessageDelayed(R.id.restart_preview, SCAN_DELAY_MS);
    }
    onContentChanged();
}

From source file:wb.android.workers.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from  w ww . j a va 2s  .co m
 *
 * @param imageView
 * @param drawable
 */
@SuppressWarnings("deprecation")
private void setImageDrawable(ImageView imageView, ProgressBar progressBar, Drawable drawable) {
    if (progressBar != null) {
        progressBar.setVisibility(View.GONE);
    }
    imageView.setVisibility(View.VISIBLE);
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:bucci.dev.freestyle.TimerActivity.java

private void showExtraRoundButton() {
    ImageView extraRoundButton = (ImageView) findViewById(R.id.extra_round_button);
    if (extraRoundButton.getVisibility() != View.VISIBLE)
        extraRoundButton.setVisibility(View.VISIBLE);

    isExtraButtonShown = true;// w  w  w.j  ava 2s .  c  o  m
}

From source file:johmphot.card.bluetooth.MultiplayerGameActivity.java

public void updateBloodUI() {

    if (game.playerHP == 4) {
        for (ImageView blood : yourBlood) {
            blood.setVisibility(View.VISIBLE);
        }/*from   w w  w . ja v a2 s. c o m*/
    } else if (game.playerHP == 3) {
        yourBlood[0].setVisibility(View.INVISIBLE);
        yourBlood[1].setVisibility(View.VISIBLE);
        yourBlood[2].setVisibility(View.VISIBLE);
        yourBlood[3].setVisibility(View.VISIBLE);
    } else if (game.playerHP == 2) {
        yourBlood[0].setVisibility(View.INVISIBLE);
        yourBlood[1].setVisibility(View.INVISIBLE);
        yourBlood[2].setVisibility(View.VISIBLE);
        yourBlood[3].setVisibility(View.VISIBLE);
    } else if (game.playerHP == 1) {
        yourBlood[0].setVisibility(View.INVISIBLE);
        yourBlood[1].setVisibility(View.INVISIBLE);
        yourBlood[2].setVisibility(View.INVISIBLE);
        yourBlood[3].setVisibility(View.VISIBLE);
    } else if (game.playerHP == 0) {
        yourBlood[0].setVisibility(View.INVISIBLE);
        yourBlood[1].setVisibility(View.INVISIBLE);
        yourBlood[2].setVisibility(View.INVISIBLE);
        yourBlood[3].setVisibility(View.INVISIBLE);

        Toast.makeText(getActivity(), "Opponent win !", Toast.LENGTH_LONG).show();

        Intent intent = new Intent(getActivity(), FinishActivity.class);
        startActivity(intent);
        getActivity().finish();
    }

    if (game.opponentHP == 4) {
        for (ImageView blood : opponentBlood) {
            blood.setVisibility(View.VISIBLE);
        }
    } else if (game.opponentHP == 3) {
        opponentBlood[0].setVisibility(View.INVISIBLE);
        opponentBlood[1].setVisibility(View.VISIBLE);
        opponentBlood[2].setVisibility(View.VISIBLE);
        opponentBlood[3].setVisibility(View.VISIBLE);
    } else if (game.opponentHP == 2) {
        opponentBlood[0].setVisibility(View.INVISIBLE);
        opponentBlood[1].setVisibility(View.INVISIBLE);
        opponentBlood[2].setVisibility(View.VISIBLE);
        opponentBlood[3].setVisibility(View.VISIBLE);
    } else if (game.opponentHP == 1) {
        opponentBlood[0].setVisibility(View.INVISIBLE);
        opponentBlood[1].setVisibility(View.INVISIBLE);
        opponentBlood[2].setVisibility(View.INVISIBLE);
        opponentBlood[3].setVisibility(View.VISIBLE);
    } else if (game.opponentHP == 0) {
        opponentBlood[0].setVisibility(View.INVISIBLE);
        opponentBlood[1].setVisibility(View.INVISIBLE);
        opponentBlood[2].setVisibility(View.INVISIBLE);
        opponentBlood[3].setVisibility(View.INVISIBLE);

        Toast.makeText(getActivity(), "You win !", Toast.LENGTH_LONG).show();

        Intent intent = new Intent(getActivity(), FinishActivity.class);
        startActivity(intent);
        getActivity().finish();
    }
    Log.i("your HP" + game.playerHP, "opponent HP" + game.opponentHP);
}

From source file:com.lastorder.pushnotifications.data.ImageDownloader.java

/**
 * Download the specified image from the Internet and binds it to the provided ImageView. The
 * binding is immediate if the image is found in the cache and will be done asynchronously
 * otherwise. A null bitmap will be associated to the ImageView if an error occurs.
 *
 * @param url The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 *//*  w  w w.ja  va  2 s . com*/

public void download(String url, ImageView imageView, Context context, ProgressBar bar) {
    resetPurgeTimer();
    Bitmap bitmap = getBitmapFromCache(url);
    myWeakContext = new WeakReference<Context>(context);

    if (bitmap == null) {
        bar.setVisibility(0);
        imageView.setVisibility(8);
        forceDownload(url, imageView, bar);
    } else {
        bar.setVisibility(8);
        cancelPotentialDownload(url, imageView);
        imageView.setImageBitmap(bitmap);
        imageView.setVisibility(0);
        imageView.bringToFront();
    }
}

From source file:de.msal.shoutemo.ui.chat.ChatFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_chat, container, false);

    /* set the fragment title of the toolbar */
    mCallback.setTitle(getString(R.string.app_name));

    /* INPUT FIELD WHERE THE MESSAGE IS COMPOSED */
    mInputField = (EditText) view.findViewById(R.id.et_input);

    /* display a blinking dot to show the refresh status */
    final ImageView updateStatus = (ImageView) view.findViewById(R.id.ib_update_indicator);
    mReceiver = new BroadcastReceiver() {
        @Override//from  w ww .  ja  va2  s.  co  m
        public void onReceive(Context context, Intent intent) {
            boolean enabled = intent.getBooleanExtra(GetPostsService.INTENT_UPDATE_ENABLED, false);
            if (enabled) {
                updateStatus.setVisibility(View.VISIBLE);
            } else {
                updateStatus.setVisibility(View.INVISIBLE);
            }
        }
    };

    /* SEND MESSAGE BUTTON */
    mSendButton = (ImageButton) view.findViewById(R.id.ib_send);
    // initially the mInputField is empty, so disable the send button
    mSendButton.setVisibility(View.GONE);
    // Send message when clicked on SEND-BUTTON
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInputField.getText() != null && !TextUtils.isEmpty(mInputField.getText())) {
                new SendPostTask(getActivity()).execute(mInputField.getText().toString());
                mInputField.setText("");
            }
        }
    });

    mEmoticonGrid = (GridView) view.findViewById(R.id.emoticons_grid);
    /* set the adapter for the emoticons */
    mEmoticonGrid
            .setAdapter(new EmoticonsAdapter(getActivity(), new EmoticonsAdapter.OnEmoticonClickListener() {
                @Override
                public void onEmoticonClick(String bbcode) {
                    mInputField.getText().replace(mInputField.getSelectionStart(),
                            mInputField.getSelectionEnd(), " " + bbcode + " ");
                }
            }));

    /* A BUTTON WHICH SWITCHES BETWEEN SOFT KEYBOARD AND EMOTICON SELECTOR */
    mKeyboardButton = (ImageButton) view.findViewById(R.id.ib_emoticons);
    /* Showing and dismissing popup on clicking EMOTICONS-BUTTON */
    mKeyboardButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mEmoticonGrid.getVisibility() == View.VISIBLE) {
                mKeyboardButton.setImageResource(R.drawable.ic_action_keyboard_alt_white_24dp);
                mEmoticonGrid.setVisibility(View.GONE);
            } else {
                mKeyboardButton.setImageResource(R.drawable.ic_action_keyboard_arrow_down_white_24dp);
                mEmoticonGrid.setVisibility(View.VISIBLE);
                hideKeyboard();
            }
        }
    });

    /* LIST STUFF */
    mListAdapter = new ListAdapter(getActivity(), null, 0);
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    listView.setVerticalScrollBarEnabled(true);
    listView.setAdapter(mListAdapter);
    this.getLoaderManager().initLoader(LOADER_ID_MESSAGES, null, this);

    return view;
}