Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin当中不显示。 #64

Open
zhew117 opened this issue Jan 10, 2020 · 3 comments
Open

kotlin当中不显示。 #64

zhew117 opened this issue Jan 10, 2020 · 3 comments

Comments

@zhew117
Copy link

zhew117 commented Jan 10, 2020

我写了Java和Kotlin两个版本
使用相同的数据和相同的Adapter
但是kotlin的版本不显示数据

代码和截图如下

`class CUQuickEditPopup(mContext: Context) : Dialog(mContext) {

init {
    val builder = AlertDialog.Builder(context)
    val view = layoutInflater.inflate(R.layout.pop_up_wheel_view, null)
    val iconWheelView = WheelView<Pair<String, Pair<Int, Int>>>(context)
    iconWheelView.setWheelAdapter(ArrayWheelIconAdapter(context))
    iconWheelView.skin = WheelView.Skin.Holo
    iconWheelView.setWheelData(iconItems)
    val timeWheelView = WheelView<String>(context)
    timeWheelView.setWheelAdapter(ArrayWheelTimeAdapter(context))
    timeWheelView.skin = WheelView.Skin.Holo
    timeWheelView.setWheelData(timeItems)
    val typeWheelView = WheelView<Pair<String, Int>>(context)
    typeWheelView.setWheelAdapter(ArrayWheelTypeAdapter(context))
    typeWheelView.skin = WheelView.Skin.Holo
    typeWheelView.setWheelData(typeItems)
    builder.setView(view)
    builder.create().show()
}

companion object {
    @JvmStatic
    val typeItems = arrayListOf("call allowed" to com.hyphenate.easeui.R.string.call_allowed,
            "text allowed" to com.hyphenate.easeui.R.string.text_allowed,
            "do not disturb" to com.hyphenate.easeui.R.string.do_not_disturb)

    @JvmStatic
    val timeItems = arrayListOf("0.5 ", "1 ", "1.5 ", "2 ", "2.5 ", "3 ")

    @JvmStatic
    val iconItems = arrayListOf(
            "meeting" to Pair(R.string.meeting, R.drawable.ease_blue_add),
            "work" to Pair(R.string.work, R.drawable.ease_blue_add),
            "study" to Pair(R.string.study, R.drawable.ease_blue_add),
            "social" to Pair(R.string.social, R.drawable.ease_blue_add),
            "meal" to Pair(R.string.meal, R.drawable.ease_blue_add),
            "entertainment" to Pair(R.string.entertainment, R.drawable.ease_blue_add))
}

}

`

`public class CUQuickEditPopupJava extends Dialog {

public CUQuickEditPopupJava(@NonNull Context context) {
    super(context);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    View view = getLayoutInflater().inflate(R.layout.pop_up_wheel_view, null);

    WheelView iconWheelView = view.findViewById(R.id.iconWheelView);
    iconWheelView.setWheelAdapter(new ArrayWheelIconAdapter(context));
    iconWheelView.setWheelData(CUQuickEditPopup.getIconItems());

    WheelView timeWheelView = view.findViewById(R.id.timeWheelView);
    timeWheelView.setWheelAdapter(new ArrayWheelTimeAdapter(context));
    timeWheelView.setWheelData(CUQuickEditPopup.getTimeItems());

    WheelView typeWheelView = view.findViewById(R.id.typeWheelView);
    typeWheelView.setWheelAdapter(new ArrayWheelTypeAdapter(context));
    typeWheelView.setWheelData(CUQuickEditPopup.getTypeItems());

    builder.setView(view);
    builder.create().show();
}

}
`

@zhew117
Copy link
Author

zhew117 commented Jan 10, 2020

不显示
Screenshot_1578619887

@zhew117
Copy link
Author

zhew117 commented Jan 10, 2020

Java版本
Screenshot_1578619933

@zhew117
Copy link
Author

zhew117 commented Jan 10, 2020

这一块抽出来想用kotlin写,发现不显示。
调试发现adapter的getview方法没有调用。bindview也就没法填充布局了。
用Java写的就没这个问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant