Skip to content

Commit

Permalink
Fix for #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesilva committed Apr 17, 2015
1 parent b511b25 commit d44682b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=1.0.6
VERSION_CODE=106
VERSION_NAME=1.0.7
VERSION_CODE=107
GROUP=com.weiwangcn.betterspinner

POM_DESCRIPTION=Android Spinner in a Better Design
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,34 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;

import com.rengwuxian.materialedittext.MaterialAutoCompleteTextView;

import java.util.Calendar;

/**
* Created by Wei on 2015/3/23.
*/
public class MaterialBetterSpinner extends MaterialAutoCompleteTextView {

public class MaterialBetterSpinner extends MaterialAutoCompleteTextView implements AdapterView.OnItemClickListener {

private static final int MAX_CLICK_DURATION = 200;
private long startClickTime;
private boolean isPopup;

public MaterialBetterSpinner(Context context) {
super(context);
setOnItemClickListener(this);
}

public MaterialBetterSpinner(Context arg0, AttributeSet arg1) {
super(arg0, arg1);
setOnItemClickListener(this);
}

public MaterialBetterSpinner(Context arg0, AttributeSet arg1, int arg2) {
super(arg0, arg1, arg2);
setOnItemClickListener(this);
}

@Override
Expand Down Expand Up @@ -77,4 +80,9 @@ public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
isPopup = false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,32 @@
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;

import java.util.Calendar;

/**
* Created by Wei on 2015/3/23.
*/
public class BetterSpinner extends AutoCompleteTextView {
public class BetterSpinner extends AutoCompleteTextView implements AdapterView.OnItemClickListener {

private static final int MAX_CLICK_DURATION = 200;
private long startClickTime;
private boolean isPopup;

public BetterSpinner(Context context) {
super(context);
setOnItemClickListener(this);
}

public BetterSpinner(Context arg0, AttributeSet arg1) {
super(arg0, arg1);
setOnItemClickListener(this);
}

public BetterSpinner(Context arg0, AttributeSet arg1, int arg2) {
super(arg0, arg1, arg2);
setOnItemClickListener(this);
}

@Override
Expand Down Expand Up @@ -76,4 +78,9 @@ public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
isPopup = false;
}

}

6 comments on commit d44682b

@harcoPro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
How i can get current selected item from Activity?

@Lesilva
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harcoPro You can use getText on the BetterSpinner that you are using.

@harcoPro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lesilva but, i use my custom item, when contains fields id, name, etc. and i want to get id value

@Lesilva
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harcoPro I'm working on something. For now you can use getText() than lookup index in the List

@azizj1
Copy link

@azizj1 azizj1 commented on d44682b Jun 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can no longer add my own setOnItemSelectedListener. The overridden methods don't get called. Furthermore, if I add the setOnItemClickListener listener, it takes two taps for it open.

@sekharrockz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still facing this issue from your library. Why did you close this issue if its really not solved.

Please sign in to comment.