Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将字符串设置为charsequence_Android_Eclipse_Charsequence - Fatal编程技术网

Android 如何将字符串设置为charsequence

Android 如何将字符串设置为charsequence,android,eclipse,charsequence,Android,Eclipse,Charsequence,我想从myDB上的表中获取数据,并向alertdialog显示数据,以下是我的代码: public void gotResult(String result, String message) { // TODO Auto-generated method stub if (result != null) { switch (Action) { case VIEW_BIKE_TYPE:

我想从myDB上的表中获取数据,并向alertdialog显示数据,以下是我的代码:

public void gotResult(String result, String message) {
        // TODO Auto-generated method stub
        if (result != null) {
            switch (Action) {
            case VIEW_BIKE_TYPE:
                try {
                    JSONObject jsonObject = null;
                    jsonObject = new JSONObject(result);
                    int response = jsonObject.getInt("result");
                    if (response != 0) {
                        JSONArray jsonArray = new JSONArray(
                                jsonObject.getString("data"));


                        CharSequence[] items = new CharSequence[jsonArray.length()];

                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject biketype = new JSONObject(jsonArray
                                    .get(i).toString());


                            items[i] = biketype.getString("type_name");
                        }
                        bike_type_Result.gotResult(items, null, Action);
                    } else {
                        String error_message = jsonObject
                                .getString("message");
                        bike_type_Result.gotResult(null, error_message,
                                Action);
                    }
                } catch (JSONException e) {
                    // TODO: handle exception
                    bike_type_Result.gotResult(null,
                            "Failed parsing data from database. Please try again.. "
                                    + e.getMessage(), Action);
                    Log.e("CON ERROR", e.getMessage());
                }
            }
        } else {
            bike_type_Result.gotResult(null, message, Action);
            Log.e("CON ERROR", message);
        }
    }
};
这是我的代码,有人能给我看一点
CharSequence[]items={……}的代码吗这样我就可以从myDB获取数据了?

请帮帮我。谢谢

只需将代码中出现的所有
CharSequence
替换为
String

就可以像这样从字符串数组转换到CharSequence,并获得所需的字符串 List listItems=new ArrayList()


我想使用charsequence将数据库中已经存在的数据显示到警报中,但我不知道如何将数据调用到警报中。你能帮我吗?
protected void onListItemClick(ListView l, View v, int position, long id) {

    final Entity_Brand brand = adapterBrand.getItem(position);

    CharSequence[] items = { ...... };

    AlertDialog.Builder builder = new AlertDialog.Builder(
            Tab_Brand_ListView_Activity.this);
    builder.setIcon(R.drawable.alert_brand_logo);
    builder.setTitle(brand.getBrand_name());
    listItems.add("Take Photo");
    listItems.add("Choose From Gallery");
    if (flagImage == 1) {
        listItems.add("Remove Photo");

    }
    listItems.add("Cancel");

    final CharSequence[] items = listItems.toArray(new CharSequence[listItems.size()]);