Coder Social home page Coder Social logo

Comments (5)

medyo avatar medyo commented on June 2, 2024

I didn't catch it, do you mean disabling focus from the Fancybutton ?

Can you paste the code you've used so i can reproduce the same issue ?

from fancybuttons.

adoji92 avatar adoji92 commented on June 2, 2024
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fancy="http://schemas.android.com/apk/res-auto"
    android:gravity="center"
    android:descendantFocusability="blocksDescendants"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <mehdi.sakout.fancybuttons.FancyButton
        android:id="@+id/fancy_button"
        fancy:fb_textColor="#000000"
        fancy:fb_iconPosition="top"
        fancy:fb_defaultColor="@android:color/transparent"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:layout_gravity="center"
        android:layout_margin="4dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

code above is view_icon_btn.xml


public class GridAdapter extends BaseAdapter {
    private static final String TAG = GridAdapter.class.getSimpleName();

    private Context mContext;
    private List<GridItem> mList;

    public GridAdapter(Context c, List<GridItem> l) {
        mContext = c;
        mList = l;
    }

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

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.d(TAG, "getView(), position: " + position);
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.view_icon_btn, parent, false);
        }

        FancyButton fbtn = ViewHolder.get(convertView, R.id.fancy_button);

        GridItem item = mList.get(position);
        fbtn.setText..
..
        return convertView;
    }
}

and this is Adapter of my grid view


mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Log.d(TAG, "onItemClick(), position: " + position);
        MainActivity2 mainActivity2 = (MainActivity2) getActivity();
        switch (position) {
            case 0:
                mainActivity2.switchFragment(DefinitionFragment.newInstance("Section A"));
                break;
            case 1:
                mainActivity2.switchFragment(DailyFragment.newInstance("Section B"));
                break;
            case 2:
                mainActivity2.switchFragment(StatMainFragment.newInstance("Section C"));
                break;
            case 3:
                mainActivity2.switchFragment(LibBookmarkFragment.newInstance("Section D"));
                break;
        }

    }
});

and this is onItemClick Listener.. (but as i mentioned, not called and fancy button.onclick() was called instead.

from fancybuttons.

medyo avatar medyo commented on June 2, 2024

Have you tried to disable the focus programmatically by doing fbtn.setFocusable(false) ?
Make sure you add it as last instruction on your getView()

from fancybuttons.

medyo avatar medyo commented on June 2, 2024

Any updates ?

from fancybuttons.

chialunwu avatar chialunwu commented on June 2, 2024

Same problem, and solved after setFocusable programmatically.
Thanks medyo!

from fancybuttons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.