材料微调器不能支持v4设备。我该如何解决?

时间:2017-09-04 08:20:21

标签: android android-layout

我正在使用材质微调器库com.github.ganfra:material-spinner:1.1.0。这个微调器工作正常所有设备。但不能使用版本4.如何解决此问题?

enter image description here

1 个答案:

答案 0 :(得分:0)

这是我的XML代码:

 <fr.ganfra.materialspinner.MaterialSpinner
                    android:id="@+id/Mobile_money_spinner_network"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_centerVertical="true"
                    android:clickable="false"
                    android:focusableInTouchMode="false"
                    android:background="@drawable/edittext_background"
                    android:popupBackground="#ffffff"
                    android:spinnerMode="dropdown"
                    android:textAlignment="textStart"
                    android:textColor="@color/black"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    app:ms_alignLabels="false"
                    app:ms_arrowColor="@color/black"
                    app:ms_arrowSize="15dp"
                    app:ms_floatingLabelColor="@color/spinner_floatlabel_color"
                    app:ms_highlightColor="@android:integer/config_shortAnimTime"
                    app:ms_hint="@string/Mobile_lable_network_textview"
                    app:ms_multiline="false"
                    app:ms_thickness="0dp"
                    app:ms_baseColor="@color/spinner_hint_color"
                    style="@style/Animation.AppCompat.DropDownUp"/>

Java文件代码::

 Spinner_network.setOnItemSelectedListener(new 
                   AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                Spinner_network.setFloatingLabelText(getResources().getString(R.string.Mobile_lable_network_selected_textview));


                if (!Spinner_network.getSelectedItem().toString().equalsIgnoreCase(getString(R.string.Mobile_lable_network_textview))) {

                    if (Spinner_network.getSelectedItem().toString().equalsIgnoreCase("vodafone")){
                        System.out.println("*****venki****network_type*****url_inside***"+Spinner_network);
                        Rl_token.setVisibility(View.VISIBLE);

                    }
                    else{
                        Rl_token.setVisibility(View.GONE);
                    }


                    isNetworkSelected = true;
                    Mobile_njetwork_selected = Spinner_network.getSelectedItem().toString();

                } else {
                    isNetworkSelected = false;
                    Mobile_njetwork_selected = getResources().getString(R.string.Mobile_lable_network_textview);
                }


            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

 //-----------------------Mobile Network----------------
    private void postRequest_mobile_network(String Url) {
        dialog = new Dialog(MobileMoneyPay.this);
        dialog.getWindow();
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.custom_loading);
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();

        TextView dialog_title = (TextView) dialog.findViewById(R.id.custom_loading_textview);
        dialog_title.setText(getResources().getString(R.string.action_processing));

        System.out.println("-------------mobile network Url----------------" + Url);

        HashMap<String, String> jsonParams = new HashMap<String, String>();
        jsonParams.put("user_id", SuserId_intent);
        jsonParams.put("ride_id", SrideId_intent);

        System.out.println("-------------------mobile_payment_rideId" + SrideId_intent);

        mRequest = new ServiceRequest(MobileMoneyPay.this);
        mRequest.makeServiceRequest(Url, Request.Method.POST, jsonParams, new ServiceRequest.ServiceListener() {
            @Override
            public void onCompleteListener(String response) {

                System.out.println("-------------mobile network Response----------------" + response);

                String Sstatus = "";
                try {

                    JSONObject object = new JSONObject(response);
                    Sstatus = object.getString("status");
                    if (Sstatus.equalsIgnoreCase("1")) {
                        JSONObject response_object = object.getJSONObject("response");
                        if (response_object.length() > 0) {

                            Object check_network_object = response_object.get("network_type");
                            if (check_network_object instanceof JSONArray) {
                                JSONArray network_array = response_object.getJSONArray("network_type");
                                if (network_array.length() > 0) {
                                    Mobilenwtwork_array.clear();
                                    for (int i = 0; i < network_array.length(); i++) {

                                        MobileNetworkPojo network_pojo = new MobileNetworkPojo();
                                        network_pojo.setNetworkType(network_array.getString(i));

                                        Mobilenwtwork_array.add(network_array.getString(i));

                                    }
                                    if (Spinner_network.getSelectedItem().toString().equalsIgnoreCase("vodafone")){
                                        System.out.println("*****venki****network_type*****url_inside***"+Spinner_network);
                                        Rl_token.setVisibility(View.VISIBLE);

                                    }
                                    else{
                                        Rl_token.setVisibility(View.GONE);
                                    }


                                    isNetworkAvailable = true;
                                } else {
                                    isNetworkAvailable = false;
                                }
                            }
                        } else {
                            isNetworkAvailable = false;
                        }
                    } else {
                        isNetworkAvailable = false;
                    }


                    if (Sstatus.equalsIgnoreCase("1") && isNetworkAvailable) {
                        ArrayAdapter<String> adapter = new ArrayAdapter<String>(MobileMoneyPay.this,
                                R.layout.mobile_network_spinner_dropdown, Mobilenwtwork_array);
                        Spinner_network.setAdapter(adapter);
//                        Spinner_network.setItems(Mobilenwtwork_array);
                    } else {
                        String Sresponse = object.getString("response");
                        Alert(getResources().getString(R.string.alert_label_title), Sresponse);
                    }

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                dialog.dismiss();
            }

            @Override
            public void onErrorListener() {
                dialog.dismiss();
            }
        });

    }