Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom preference not clickable

I added a custom preference to my project (code below). I added it to my preferences xml with a custom widgetLayout:

<w.PlusOnePreference 
    android:title="Rate App"
    android:key="custom"
    android:widgetLayout="@layout/plusone_pref"/>

Preference layout xml:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.plus.PlusOneButton    
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
android:id="@+id/plus_one_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="false"
plus:size="standard" />

I see the layout and the button in the layout works fine. The only problem is that the preference isn't clickable. Like it's hidden behind something.

Any ideas on how to make it clickable?

If I add a regular Preference (without a widget layout) it works fine.

Thanks.

public class PlusOnePreference extends Preference {

private PlusClient mPlusClient = null; 

public PlusOnePreference(Context context) {
    super(context);

}


public PlusOnePreference(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public PlusOnePreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public void setPlusClient(PlusClient plusClient) {
    mPlusClient = plusClient;
}



@Override
protected void onBindView(View view) {
    super.onBindView(view);     
    //mPlusOneButton = 
    PlusOneButton plusOneButton = (PlusOneButton)view.findViewById(R.id.plus_one_button);
    plusOneButton.initialize(mPlusClient, SettingsActivity.URL, SettingsActivity.PLUS_ONE_REQUEST_CODE);
}
  }
like image 260
Ran Avatar asked Jul 26 '26 10:07

Ran


1 Answers

in layout/plusone_pref.xml set android:focusable="false" for your Button

like image 105
pskink Avatar answered Jul 28 '26 00:07

pskink



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!