Example usage for android.widget ImageView setOnClickListener

List of usage examples for android.widget ImageView setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.example.fertilizercrm.easemob.chatuidemo.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;//from   w w  w.  j a  va2  s . com
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);

    //???
    blackList = EMContactManager.getInstance().getBlackListUsernames();
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();

    //?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);

            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else if (Constant.CHAT_ROOM.equals(username)) {
                //??
                startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class));
            } else if (Constant.CHAT_ROBOT.equals(username)) {
                //Robot?
                startActivity(new Intent(getActivity(), RobotsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), AddContactActivity.class));
        }
    });
    registerForContextMenu(listView);

    progressBar = (View) getView().findViewById(R.id.progress_bar);

    contactSyncListener = new HXContactSyncListener();
    HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener);

    blackListSyncListener = new HXBlackListSyncListener();
    HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener);

    contactInfoSyncListener = new HXContactInfoSyncListener();
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager()
            .addSyncContactInfoListener(contactInfoSyncListener);

    if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }

    View view = getView().findViewById(R.id.rl_left);
    view.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
}

From source file:es.usc.citius.servando.calendula.fragments.MedicineCreateOrEditFragment.java

void setupMedPresentationChooser(final View rootView) {
    View.OnClickListener listener = new View.OnClickListener() {
        @Override//from   ww  w.ja  va 2 s  .  c o m
        public void onClick(View view) {
            onClickMedicine(view.getId(), rootView);
        }
    };
    for (View v : getViewsByTag((ViewGroup) rootView, "med_type")) {
        ImageView iv = (ImageView) v;
        iv.setOnClickListener(listener);
        switch (v.getId()) {

        case R.id.med_presentation_2:
            iv.setImageDrawable(iconFor(Presentation.CAPSULES));
            break;
        case R.id.med_presentation_3:
            iv.setImageDrawable(iconFor(Presentation.EFFERVESCENT));
            break;
        case R.id.med_presentation_4:
            iv.setImageDrawable(iconFor(Presentation.PILLS));
            Log.d(getTag(), "Pill");
            break;
        case R.id.med_presentation_5:
            iv.setImageDrawable(iconFor(Presentation.SYRUP));
            break;
        case R.id.med_presentation_6:
            iv.setImageDrawable(iconFor(Presentation.DROPS));
            break;
        case R.id.med_presentation_7:
            iv.setImageDrawable(iconFor(Presentation.SPRAY));
            break;
        case R.id.med_presentation_8:
            iv.setImageDrawable(iconFor(Presentation.INHALER));
            break;
        case R.id.med_presentation_9:
            iv.setImageDrawable(iconFor(Presentation.INJECTIONS));
            break;
        case R.id.med_presentation_10:
            iv.setImageDrawable(iconFor(Presentation.POMADE));
            break;
        case R.id.med_presentation_11:
            iv.setImageDrawable(iconFor(Presentation.PATCHES));
            break;
        }

    }
}

From source file:cn.ucai.chatuidemo.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;//  w ww . ja  va  2  s  .  co  m
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);

    //???
    blackList = EMContactManager.getInstance().getBlackListUsernames();
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();

    //?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);

            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else if (Constant.CHAT_ROOM.equals(username)) {
                //??
                startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class));
            } else if (Constant.CHAT_ROBOT.equals(username)) {
                //Robot?
                startActivity(new Intent(getActivity(), RobotsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), AddContactActivity.class));
        }
    });
    registerForContextMenu(listView);

    progressBar = (View) getView().findViewById(R.id.progress_bar);

    contactSyncListener = new HXContactSyncListener();
    HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener);

    blackListSyncListener = new HXBlackListSyncListener();
    HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener);

    contactInfoSyncListener = new HXContactInfoSyncListener();
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager()
            .addSyncContactInfoListener(contactInfoSyncListener);

    if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }
    UpdateContactListLitener();
}

From source file:cn.ucai.SuperWechat.activity.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;/*  www.  j a  v a  2s.com*/
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    sidebar.setListView(listView);

    //???
    blackList = EMContactManager.getInstance().getBlackListUsernames();
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();

    //?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);

            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else if (Constant.CHAT_ROOM.equals(username)) {
                //??
                startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class));
            } else if (Constant.CHAT_ROBOT.equals(username)) {
                //Robot?
                startActivity(new Intent(getActivity(), RobotsActivity.class));
            } else {
                // demo??
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId",
                        adapter.getItem(position).getUsername()));
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), AddContactActivity.class));
        }
    });
    registerForContextMenu(listView);

    progressBar = (View) getView().findViewById(R.id.progress_bar);

    contactSyncListener = new HXContactSyncListener();
    HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener);

    blackListSyncListener = new HXBlackListSyncListener();
    HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener);

    contactInfoSyncListener = new HXContactInfoSyncListener();
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager()
            .addSyncContactInfoListener(contactInfoSyncListener);

    if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) {
        progressBar.setVisibility(View.VISIBLE);
    } else {
        progressBar.setVisibility(View.GONE);
    }
    setMupdateContactReceiver();
}

From source file:es.ubiqua.atractivas.GaleryPageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Imagen imagen = ((GaleryActivity) getActivity()).m_parts.get(mPageNumber);
    Rss rss = ((GaleryActivity) getActivity()).rss;

    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_galery_page, container, false);

    FontLoader.overrideFonts(rootView, "normal");

    NoAutoScrollView scroll = (NoAutoScrollView) rootView.findViewById(R.id.content);

    scroll.setOnEndScrollListener(new NoAutoScrollView.OnEndScrollListener() {
        @Override/*from   w  w  w  .jav  a 2  s .c  om*/
        public void onEndScroll(boolean home, boolean end) {
            if (home || end) {
                ((GaleryActivity) getActivity()).showButtons();
            } else {
                ((GaleryActivity) getActivity()).hideButtons();
            }
        }
    });

    // Set the title view to show the page number.
    ((TextView) rootView.findViewById(R.id.DetalleCategoria)).setText(rss.getCategory());
    ImageView favorito = (ImageView) rootView.findViewById(R.id.DetalleFavorito);
    favorito.setTag(rss);
    if (rss.getFavorito()) {
        favorito.setImageDrawable(ApplicationApp.getDrawable("favoritos_selected"));
    } else {
        favorito.setImageDrawable(ApplicationApp.getDrawable("favoritos"));
    }
    ((TextView) rootView.findViewById(R.id.DetalleTitulo)).setText(rss.getTitle());

    favorito.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageView imagen = (ImageView) view;

            RssDataSource _rssDataSource = new RssDataSource(getActivity().getApplicationContext());
            try {
                _rssDataSource.open();
            } catch (SQLException e) {
                //                  Log.d( "action fragment_category", "Enter: handleMessage -> " + e.getMessage() );
            }
            Rss rss = (Rss) imagen.getTag();
            rss.setFavorito(!rss.getFavorito());
            _rssDataSource.updateFavorito(rss.getId(), rss.getFavorito());

            if (rss.getFavorito()) {
                imagen.setImageDrawable(ApplicationApp.getDrawable("favoritos_selected"));
            } else {
                imagen.setImageDrawable(ApplicationApp.getDrawable("favoritos"));
            }
            ((GaleryActivity) getActivity()).rss = rss;
            _rssDataSource.close();
        }
    });
    // whenever you want to load an image from url
    // call DisplayImage function
    // url - image url to load
    // loader - loader image, will be displayed before getting image
    // image - ImageView

    imgLoader.DisplayImage(imagen.getUrl(), R.drawable.placeholder_detalle,
            (ImageView) rootView.findViewById(R.id.DetalleImagen));

    ((WebView) rootView.findViewById(R.id.DestalleFulltext)).loadData(HEADER + imagen.getTexto() + FOOTER,
            "text/html; charset=UTF-8", null);

    yocAdBannerViewb = (YocAdViewContainer) rootView.findViewById(R.id.baner_publicidad);
    if (rss.getParentCategory().equals(new String("En Forma"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_ENFORMA_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Salud"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_SALUD_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Moda"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_MODA_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Nutricin"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_NUTRI_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Belleza"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_BELLEZA_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_GENERAL_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    }

    createLigAdView(ApplicationApp.LigatusId, rootView);

    return rootView;
}

From source file:com.mobicage.rogerthat.GroupDetailActivity.java

private void updateView() {
    T.UI();/*from ww  w .  ja  v  a2s .  com*/
    final ImageView image = (ImageView) findViewById(R.id.friend_avatar);
    final ImageView newGroupAvatar = ((ImageView) findViewById(R.id.update_group_avatar_img));

    final Bitmap avatarBitmap = mFriendsPlugin.toGroupBitmap(mGroup.avatar);
    image.setImageBitmap(avatarBitmap);
    newGroupAvatar.setImageBitmap(avatarBitmap);

    final TextView nameView = (TextView) findViewById(R.id.friend_name);
    nameView.setText(mGroup.name);
    mUpdateGroupName.setText(mGroup.name);

    final Button saveBtn = (Button) findViewById(R.id.save_group);
    saveBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mEditing) {
                if (mUpdateGroupName.getText().length() == 0) {
                    UIUtils.showDialog(GroupDetailActivity.this, null, R.string.name_required);
                    return;
                }

                if (mGroup.members.size() == 0) {
                    UIUtils.showDialog(GroupDetailActivity.this, null, R.string.members_are_required);
                    return;
                }
            }
            updateGroupLayout(!mEditing);
            // We need to remove all the views because of a bug in samsung galaxy S2
            // which does not remove items in the listview if smaller then the screen
            mLinearLayout.removeAllViews();
            mLinearLayout = (LinearLayout) LayoutInflater.from(GroupDetailActivity.this)
                    .inflate(R.layout.group_detail, null);
            setContentView(mLinearLayout);

            // END
            updateView();
        }
    });

    final ImageView editBtn = (ImageView) findViewById(R.id.edit_group);
    editBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            T.UI();
            updateGroupLayout(!mEditing);
            updateView();
        }
    });

    final Button cancelBtn = (Button) findViewById(R.id.cancel);
    cancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            T.UI();
            if (mIsNewGroup) {
                mFriendsPlugin.getStore().deleteGroup(mGroup.guid);

                Intent intent = new Intent(FriendsPlugin.GROUP_REMOVED);
                intent.putExtra("guid", mGroup.guid);
                mService.sendBroadcast(intent);
                mGroup = null;
            }
            finish();
        }
    });

    initListView();

    setTitle(mGroup.name);
}

From source file:es.ubiqua.atractivas.ArticlePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rss = ((ArticleActivity) getActivity()).m_parts.get(mPageNumber);
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_article_page, container, false);

    FontLoader.overrideFonts(rootView, "bold");

    NoAutoScrollView scroll = (NoAutoScrollView) rootView.findViewById(R.id.content);

    if (((ArticleActivity) getActivity()).m_parts.size() <= 1) {
        ((ArticleActivity) getActivity()).hideButtons();
    } else {/*from  www.  j a v a  2s  . co  m*/
        scroll.setOnEndScrollListener(new NoAutoScrollView.OnEndScrollListener() {
            @Override
            public void onEndScroll(boolean home, boolean end) {
                if (home || end) {
                    ((ArticleActivity) getActivity()).showButtons();
                } else {
                    ((ArticleActivity) getActivity()).hideButtons();
                }
            }
        });
    }

    // Set the title view to show the page number.
    ((TextView) rootView.findViewById(R.id.DetalleCategoria)).setText(rss.getCategory());
    ImageView favorito = (ImageView) rootView.findViewById(R.id.DetalleFavorito);
    favorito.setTag(rss);
    if (rss.getFavorito()) {
        favorito.setImageDrawable(ApplicationApp.getDrawable("favoritos_selected"));
    } else {
        favorito.setImageDrawable(ApplicationApp.getDrawable("favoritos"));
    }
    ((TextView) rootView.findViewById(R.id.DetalleTitulo)).setText(rss.getTitle());

    favorito.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageView imagen = (ImageView) view;

            RssDataSource _rssDataSource = new RssDataSource(getActivity().getApplicationContext());
            try {
                _rssDataSource.open();
            } catch (SQLException e) {
                //                  Log.d( "action fragment_category", "Enter: handleMessage -> " + e.getMessage() );
            }
            Rss rss = (Rss) imagen.getTag();
            rss.setFavorito(!rss.getFavorito());
            _rssDataSource.updateFavorito(rss.getId(), rss.getFavorito());

            if (rss.getFavorito()) {
                imagen.setImageDrawable(ApplicationApp.getDrawable("favoritos_selected"));
            } else {
                imagen.setImageDrawable(ApplicationApp.getDrawable("favoritos"));
            }
            _rssDataSource.close();
        }
    });
    // whenever you want to load an image from url
    // call DisplayImage function
    // url - image url to load
    // loader - loader image, will be displayed before getting image
    // image - ImageView

    imgLoader.DisplayImage(rss.getImage(), R.drawable.placeholder_detalle,
            (ImageView) rootView.findViewById(R.id.DetalleImagen));

    ((WebView) rootView.findViewById(R.id.DestalleFulltext)).loadData(HEADER + rss.getFullText() + FOOTER,
            "text/html; charset=UTF-8", null);

    yocAdBannerViewb = (YocAdViewContainer) rootView.findViewById(R.id.baner_publicidad);
    if (rss.getParentCategory().equals(new String("En Forma"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_ENFORMA_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Salud"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_SALUD_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Moda"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_MODA_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Nutricin"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_NUTRI_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else if (rss.getParentCategory().equals(new String("Belleza"))) {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_BELLEZA_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    } else {
        _yocAdManagerb = new YocAdManager(getActivity(), ApplicationApp.YOC_TAG_GENERAL_BANNER,
                AdSize.BANNER_SMARTPHONE_480x80, new AdBanner());
    }

    createLigAdView(ApplicationApp.LigatusId, rootView);

    return rootView;
}

From source file:de.skubware.opentraining.activity.start_training.TrainingEntryListAdapter.java

public View getView(final int position, View convertView, ViewGroup parent) {
    View vi = convertView;/*from   w  w w  .ja va2s  .com*/

    // last element is an empty row
    if (position == getCount() - 1) {
        vi = mInflater.inflate(R.layout.list_row_empty, null);

        // add listener
        vi.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                showDialog(null, -1);
            }
        });

        return vi;
    }

    vi = mInflater.inflate(R.layout.list_row, null);
    final FSet set = (FSet) getItem(position);

    // set values
    TextView textview_weight = (TextView) vi.findViewById(R.id.textview_weight);
    TextView textview_rep = (TextView) vi.findViewById(R.id.textview_rep);
    TextView textview_duration = (TextView) vi.findViewById(R.id.textview_duration);

    for (SetParameter para : set.getSetParameters()) {
        if (para instanceof SetParameter.Weight) {
            textview_weight.setText(para.toString());
        }
        if (para instanceof SetParameter.Duration) {
            textview_duration.setText(para.toString());
        }
        if (para instanceof SetParameter.Repetition) {
            textview_rep.setText(para.toString());
        }
    }

    // set button icons
    final ImageButton imagebutton_check = (ImageButton) vi.findViewById(R.id.imagebutton_check);
    if (mTrainingEntry.hasBeenDone(set)) {
        imagebutton_check.setImageResource(R.drawable.icon_check_green);
    } else {
        imagebutton_check.setImageResource(R.drawable.icon_check_white);
    }

    // add button listener

    imagebutton_check.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            imagebutton_check.setImageResource(R.drawable.icon_check_green);
            mTrainingEntry.setHasBeenDone(set, true);
            trainingEntryEdited();

            if (mFEx.isTrainingEntryFinished(mTrainingEntry)) {
                showExerciseFinishedDialog();
            }
        }
    });

    // add lister for changing values
    final ImageView imageview_weight = (ImageView) vi.findViewById(R.id.imageview_weight);
    final ImageView imageview_rep = (ImageView) vi.findViewById(R.id.imageview_rep);
    final ImageView imageview_duration = (ImageView) vi.findViewById(R.id.imageview_duration);

    OnClickListener changeSetValuesListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            showDialog(set, position);
        }
    };
    imageview_weight.setOnClickListener(changeSetValuesListener);
    imageview_rep.setOnClickListener(changeSetValuesListener);
    imageview_duration.setOnClickListener(changeSetValuesListener);

    return vi;
}

From source file:com.sim2dial.dialer.ContactFragment.java

private void displayContact(LayoutInflater inflater, View view) {
    AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);
    if (contact.getPhotoUri() != null) {
        InputStream input = Compatibility.getContactPictureInputStream(
                LinphoneActivity.instance().getContentResolver(), contact.getID());
        contactPicture.setImageBitmap(BitmapFactory.decodeStream(input));
    } else {//from w  w  w  .j a  v  a  2 s.co  m
        contactPicture.setImageResource(R.drawable.unknown_small);
    }

    TextView contactName = (TextView) view.findViewById(R.id.contactName);
    contactName.setText(contact.getName());

    TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
    controls.removeAllViews();
    for (String numberOrAddress : contact.getNumerosOrAddresses()) {
        View v = inflater.inflate(R.layout.contact_control_row, null);

        String displayednumberOrAddress = numberOrAddress;
        if (numberOrAddress.startsWith("sip:")) {
            displayednumberOrAddress = displayednumberOrAddress.substring(4);
        }

        TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
        tv.setText(displayednumberOrAddress);
        tv.setSelected(true);

        if (!displayChatAddressOnly) {
            v.findViewById(R.id.dial).setOnClickListener(dialListener);
            v.findViewById(R.id.dial).setTag(displayednumberOrAddress);
        } else {
            v.findViewById(R.id.dial).setVisibility(View.GONE);
        }

        v.findViewById(R.id.chat).setOnClickListener(chatListener);
        if (LinphoneUtils.isSipAddress(numberOrAddress)) {
            v.findViewById(R.id.chat).setTag(numberOrAddress);
        } else {
            LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
            if (lpc != null) {
                if (!numberOrAddress.startsWith("sip:")) {
                    numberOrAddress = "sip:" + numberOrAddress;
                }
                v.findViewById(R.id.chat).setTag(numberOrAddress + "@" + lpc.getDomain());
            }
        }

        final String finalNumberOrAddress = numberOrAddress;
        ImageView friend = (ImageView) v.findViewById(R.id.addFriend);
        if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) {
            friend.setVisibility(View.VISIBLE);

            boolean isAlreadyAFriend = LinphoneManager.getLc()
                    .findFriendByAddress(finalNumberOrAddress) != null;
            if (!isAlreadyAFriend) {
                friend.setImageResource(R.drawable.friend_add);
                friend.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) {
                            displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
                        }
                    }
                });
            } else {
                friend.setImageResource(R.drawable.friend_remove);
                friend.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) {
                            displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
                        }
                    }
                });
            }
        }

        if (getResources().getBoolean(R.bool.disable_chat)) {
            v.findViewById(R.id.chat).setVisibility(View.GONE);
        }

        controls.addView(v);
    }
}

From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_explain_moshaver);
    Fabric.with(this, new Crashlytics());

    alagestarmoshaver = (ImageView) findViewById(R.id.alagestarmoshaver);

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            placeid = "";
        } else {//  w w w. jav a  2 s  .  c  om
            placeid = extras.getString("placeid");
        }
    } else {
        placeid = (String) savedInstanceState.getSerializable("placeid");
    }

    ImageView imageView1 = (ImageView) findViewById(R.id.backButton);
    imageView1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ExplainMoshaver.this, PageMoshaverin.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(intent);
        }
    });

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    ImageView imageView = (ImageView) findViewById(R.id.menuButton);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawer.openDrawer(Gravity.END);
        }
    });

    if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {
        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(true);
        nav_Menu.findItem(R.id.nav_login).setVisible(false);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(true);
    } else {
        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(false);
        nav_Menu.findItem(R.id.nav_login).setVisible(true);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(false);
    }

    userimg = (ImageView) findViewById(R.id.adviser_image);
    name_moshaver_textview = (TextView) findViewById(R.id.name_moshaver_textview);
    //taxassose_moshaver_textview =(TextView) findViewById(R.id.taxassose_moshaver_textview);
    code_moshaver_textview = (TextView) findViewById(R.id.code_moshaver_textview);

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            adviseridm = "0";
        } else {
            adviseridm = extras.getString("adviserid");
        }
    } else {
        adviseridm = (String) savedInstanceState.getSerializable("adviserid");
    }

    //Toast.makeText(getApplicationContext(), "+"+adviseridm+"+", Toast.LENGTH_LONG).show();

    if (isOnline()) {
        //requestData();

        postgetData();
        //Log.i("Lieseesene",License);

        ImageView imageView2 = (ImageView) findViewById(R.id.adviser_about_img);
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //requestDataa();

                if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {

                    Intent intent3 = new Intent(ExplainMoshaver.this, PageRezerv.class);
                    intent3.putExtra("adviseridm", adviseridm);
                    intent3.putExtra("placeid", placeid);
                    intent3.putExtra("namemoshaver", namemoshaver);

                    startActivity(intent3);

                } else {
                    Toast.makeText(getApplicationContext(), "    ",
                            Toast.LENGTH_LONG).show();
                }

            }
        });

        //
        // final ImageView alagestarmarkaz = (ImageView)findViewById(R.id.alagestarmarkaz);

        alagestarmoshaver.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcpsdcpsdcpsdc"+alagestarmarkaz.getResources());

                if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {

                    setAlage();
                    //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcp2sdcpsdcpsdc"+hanyayo);

                } else {
                    Toast.makeText(getApplicationContext(), "    ",
                            Toast.LENGTH_LONG).show();
                }
            }
        });

        ImageView adviser_reserve_img = (ImageView) findViewById(R.id.adviser_reserve_img);
        adviser_reserve_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final LinearLayout darbareyehuseyin = (LinearLayout) findViewById(R.id.darbareyehuseyin);
                darbareyehuseyin.setVisibility(View.VISIBLE);
                TextView textTagsHusseyin = (TextView) findViewById(R.id.textTagsHusseyin);
                try {
                    textTagsHusseyin.setText(Tagggggggs);
                    ImageView closeafzundanejavab = (ImageView) findViewById(R.id.closeinvisibleimag);
                    closeafzundanejavab.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            darbareyehuseyin.setVisibility(View.GONE);
                        }
                    });

                } catch (Exception e) {
                    textTagsHusseyin.setText("");
                }

            }
        });

    } else {
        Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show();
    }
}