-4

i have created a custom list view. in its layout have created an Edit text. but i am unable to edit inside this edit text.

list.setAdapter(new yourAdapter(NewActivity.this, new String[] { "test1",
            "test2","test3" }));

and my yourAdapter class is

class yourAdapter extends BaseAdapter {

Context context;
String[] data;
private static LayoutInflater inflater = null;

public yourAdapter(Context context, String[] data) {
    // TODO Auto-generated constructor stub
    this.context = context;
    this.data = data;
    inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return data.length;
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return data[position];
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}



@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View vi = convertView;
    if (vi == null)
        for(int i =0; i<=getCount();i++){
            if(data[position].equals("grouped")){
                vi = inflater.inflate(R.layout.multipleselect, null);
            }
            else if(data[position].equals("kuchbhi"))
                vi = inflater.inflate(R.layout.yes_or_no, null);
            else {
                vi = inflater.inflate(R.layout.write_answer, null);
                //edit_text
                EditText edit_text = (EditText) vi.findViewById(R.id.edit_text);
            }


        }

   /* TextView text = (TextView) vi.findViewById(R.id.text);
    text.setText(data[position]);*/
    return vi;
}

}

i can not edit in edit_text. when i click edit text keyboard open but nothing shows inside edit text.

Aks
  • 11
  • 7

2 Answers2

0

Marshmallow ask for permissions manually. No doubt you must have already added location permission in your manifest file but now you also need to add some code to ask manually for permission. You can use this library https://github.com/Karumi/Dexter

0
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        if (checkPermission()) {
                            //do your work
                        } else {
                            requestPermission();
                        }
                    }
           }


            protected boolean checkPermission() {
                int result = ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION);
                if (result == PackageManager.PERMISSION_GRANTED) {
                    return true;
                } else {
                    return false;
                }
            }

            protected void requestPermission() {

                if (ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.ACCESS_FINE_LOCATION)) {
                    Toast.makeText(this, "Write External Storage permission allows us to do store images. Please allow this permission in App Settings.", Toast.LENGTH_LONG).show();
                } else {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        requestPermissions(new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 100);
                    }
                }
            }

        @Override
        public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
            switch (requestCode) {
                case 100:
                    if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                        //do your work
                    } else {
                        Log.e("value", "Permission Denied, You cannot use local drive .");
                    }
                    break;
            }
        }
Kush Patel
  • 1,228
  • 1
  • 13
  • 34