Android 文本视图中不可见的文本

Android 文本视图中不可见的文本,android,Android,我无法以任何方式显示TextView的文本。我已经尝试过各种方法,因为它是一种静态方法,所以我必须调用此函数: sendQuery.text.setText(provola); 这是第二节课: public class sendQuery extends main { // ///////// Public method to send Query /////////// public static String send(String query, Activity send

我无法以任何方式显示TextView的文本。我已经尝试过各种方法,因为它是一种静态方法,所以我必须调用此函数:

sendQuery.text.setText(provola);
这是第二节课:

public class sendQuery extends main {
    // ///////// Public method to send Query ///////////
    public static String send(String query, Activity sendQuery) {
        String result = "0";
        InputStream is = null;
        String weekDayVal = null;
        String provola = null;
        // the query to send
        ArrayList<NameValuePair> querySend = new ArrayList<NameValuePair>();

        querySend.add(new BasicNameValuePair("querySend", query));

        // http post
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(
                    "http://locali.altervista.org/php/locali.php");
            httppost.setEntity(new UrlEncodedFormEntity(querySend));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        } catch (Exception e) {
            Log.e("log_tag", "Error in http connection " + e.toString());
        }

        // convert response to string
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
            try {
                TextView text = (TextView) sendQuery
                        .findViewById(R.id.textView10);
                JSONArray weekDetails = new JSONArray(result); // Your response
                                                                // string
                for (int index = 0; index < 1/* weekDetails.length() */; index++) {
                    JSONObject tempWeekDetail = weekDetails
                            .getJSONObject(index);
                    weekDayVal = tempWeekDetail.getString("Lunedi");// Value for
                                                                    // Monday
                    // added this Log which you can view from LogCat. also
                    // changed above variable name
                    Log.i("Resp Value", "Moday Value " + weekDayVal);
                    JSONObject provino = weekDetails.getJSONObject(index);
                    provola = provino.getString("Martedi");// Value for Monday
                    // added this Log which you can view from LogCat. also
                    // changed above variable name
                    Log.i("Resp Value", "Moday Value " + provola);
                    text.setText(provola);
                }
            } catch (Exception e) {

            }
        } catch (Exception e) {
            Log.e("log_tag", "Error converting result: " + e.toString());
        }

        Log.i("SendQUERY", result);
        return result;
    }
}

变量“provola”中的值存在,但不显示任何内容。谢谢。

resLayout是Textview类型的变量。 您应该这样做,而不是
追加
:-

resLayout.setText("Your String goes here in quotes or a variable without the quotes");
您说您得到变量“res”中的值“instrige”


TextView
text
添加到活动中的位置?此处为text.setText(provola);main.xml是否有id为
textView10
的textview?和
send(“从contatti中选择*”,空)您拥有的空广告
发送(字符串查询、活动sendQuery){
一个更大的问题似乎是,你在主线程上做这些网络工作,这是一个否。你应该在后台线程中这样做,然后在完成后更新
UI
。因此,你可能会得到一个异常,它返回
null
@ddd你的应用程序会崩溃吗???\n问题不在这里text.setText(provola);在
TextView
上使用
append()
有什么问题?
resLayout.setText("Your String goes here in quotes or a variable without the quotes");
String res = sendQuery.send("SELECT * FROM contatti", null);
resLayout.append(res); // Dont do this
resLayout.setText(res); // Do this