数据显示在logcat中,但不显示在文本视图中。我能做什么
这是我的日志
12-29 11:05:13.908: D/gralloc_goldfish(772): Emulator without GPU emulation detected. 12-29 11:05:24.649: D/dalvikvm(772): GC_FOR_ALLOC freed 195K, 9% free 7439K/8135K, paused 35ms, total 38ms 12-29 11:05:26.458: D/dalvikvm(772): GC_CONCURRENT freed 229K, 10% free 7628K/8455K, paused 26ms+99ms, total 185ms 12-29 11:05:27.908: D/Create Response(772): {"message":"Login successfully.","success":1} 12-29 11:05:28.598: I/Choreographer(772): Skipped 52 frames! The application may be doing too much work on its main thread. 12-29 11:05:29.848: D/Create Response(772): {"3":"jmi.mohsin@gmail.com","2":"myname","1":"msnmsn","0":"8527801400","mobile_number":"8527801400","hint":"myname","email_id":"jmi.mohsin@gmail.com","password":"msnmsn"} 12-29 11:05:29.848: I/JSON parse(772): myname 12-29 11:05:29.878: W/System.err(772): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 12-29 11:05:29.878: W/System.err(772): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4609) 12-29 11:05:29.878: W/System.err(772): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:835) 12-29 11:05:29.878: W/System.err(772): at android.view.View.requestLayout(View.java:15129) 12-29 11:05:29.878: W/System.err(772): at android.view.View.requestLayout(View.java:15129) 12-29 11:05:29.878: W/System.err(772): at android.view.View.requestLayout(View.java:15129) 12-29 11:05:29.888: W/System.err(772): at android.view.View.requestLayout(View.java:15129) 12-29 11:05:29.888: W/System.err(772): at android.view.View.requestLayout(View.java:15129) 12-29 11:05:29.888: W/System.err(772): at android.widget.TextView.checkForRelayout(TextView.java:6303) 12-29 11:05:29.888: W/System.err(772): at android.widget.TextView.setText(TextView.java:3547) 12-29 11:05:29.888: W/System.err(772): at android.widget.TextView.setText(TextView.java:3405) 12-29 11:05:29.888: W/System.err(772): at android.widget.TextView.setText(TextView.java:3380) 12-29 11:05:29.898: W/System.err(772): at com.example.phonebook.Welcome$loginAccess.doInBackground(Welcome.java:93) 12-29 11:05:29.898: W/System.err(772): at com.example.phonebook.Welcome$loginAccess.doInBackground(Welcome.java:1) 12-29 11:05:29.898: W/System.err(772): at android.os.AsyncTask$2.call(AsyncTask.java:287) 12-29 11:05:29.898: W/System.err(772): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-29 11:05:29.898: W/System.err(772): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-29 11:05:29.898: W/System.err(772): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 12-29 11:05:29.908: W/System.err(772): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-29 11:05:29.908: W/System.err(772): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-29 11:05:29.908: W/System.err(772): at java.lang.Thread.run(Thread.java:856)
package com.example.phonebook; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.JSONObject; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.os.StrictMode; import android.util.Log; import android.widget.TextView; public class Welcome extends Activity { // private ProgressDialog pDialog; TextView jsonParsed1,DataShow,hint_data; JSONParser jsonParser = new JSONParser(); JSONParser jobj = new JSONParser(); private static String url = "http://192.168.1.10/android_connect/login_setup/show_data.php"; //private static final String about = "about"; // private static final String TAG_SUCCESS="success"; // private static final String hint="hint"; @Override protected void onCreate(Bundle savedInstanceState) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads().detectDiskWrites().detectNetwork() .penaltyLog().build()); super.onCreate(savedInstanceState); setContentView(R.layout.welcome); jsonParsed1=(TextView)findViewById(R.id.jsonParsed); DataShow=(TextView)findViewById(R.id.show_all_data); hint_data=(TextView)findViewById(R.id.hint_datafor_value); String abt = getIntent().getStringExtra("mobile_number"); //Intent i=getIntent(); //String abt=i.getStringExtra("mobile_number"); //System.out.println(abt); //jsonParsed1.setText(abt); new loginAccess().execute(); } class loginAccess extends AsyncTask { TextView jsonParsed = (TextView) findViewById(R.id.jsonParsed); private String Content; String OutputData = ""; JSONObject jsonResponse; @Override protected String doInBackground(String... arg0) { String abt = getIntent().getStringExtra("mobile_number"); List params = new ArrayList(); params.add(new BasicNameValuePair("mobile_number", abt)); JSONObject json = jsonParser.makeHttpRequest(url,"POST", params); Content = json.toString(); Log.d("Create Response", Content); /****************** Start Parse Response JSON Data *************/ try { /****** Creates a new JSONObject with name/value mappings from the JSON string. ********/ jsonResponse = new JSONObject(Content); /******* Fetch node values **********/ String hint = jsonResponse.optString("hint").toString(); OutputData += "Node : \n\n "+ hint +" "; Log.i("JSON parse", hint); /****************** End Parse Response JSON Data *************/ // jsonParsed.setText( OutputData ); } catch (Exception e) { e.printStackTrace(); } return null; } protected void onPostExecute(Void unused) { // //JSONObject jsonResponse = null; // // /******* Fetch node values **********/ // String hint = jsonResponse.optString("hint").toString(); // // OutputData += "Node : \n\n "+ hint +" "; // // Log.i("JSON parse", hint); // // /****************** End Parse Response JSON Data *************/ // // hint_data.setText( OutputData ); jsonParsed.setText( OutputData ); } } }
这样修改你的异步任务:做asynctask的后台方法是在非UI线程中运行的,所以我们不能从DoinBackgroad中修改UI元素,所以我们必须返回结果,这样结果就会作为参数进入postExecute方法中,然后我们就可以修改UI了
package com.example.phonebook;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.widget.TextView;
import com.afbb.animationtest.R;
public class Welcome extends Activity {
TextView jsonParsed1,DataShow,hint_data;
TextView jsonParsed ;
JSONParser jsonParser = new JSONParser();
JSONParser jobj = new JSONParser();
private static String url = "http://192.168.1.10/android_connect/login_setup/show_data.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads().detectDiskWrites().detectNetwork()
.penaltyLog().build());
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
jsonParsed1=(TextView)findViewById(R.id.jsonParsed);
DataShow=(TextView)findViewById(R.id.show_all_data);
hint_data=(TextView)findViewById(R.id.hint_datafor_value);
jsonParsed = (TextView) findViewById(R.id.jsonParsed);
String abt = getIntent().getStringExtra("mobile_number");
new loginAccess().execute();
}
class loginAccess extends AsyncTask<String,Void,JSONObject> {
private String Content;
@Override
protected JSONObject doInBackground(String... arg0) {
String abt = getIntent().getStringExtra("mobile_number");
List params = new ArrayList();
params.add(new BasicNameValuePair("mobile_number", abt));
JSONObject json = jsonParser.makeHttpRequest(url,"POST", params);
Content = json.toString();
Log.d("Create Response", Content);
/****************** Start Parse Response JSON Data *************/
try {
JSONObject jsonResponse = new JSONObject(Content);
String hint = jsonResponse.optString("hint").toString();
return jsonResponse;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(JSONObject result) {
//Parse and update the UI
jsonParsed.setText( OutputData );
}
}
}
i
我的数据确实显示在console.log中,但实际上没有显示在表中,我在这里做错了什么?
谁能引导我过去吗?也许我的效用不好?
我已经制作了Hello World RCP应用程序,得到了以下类结构: 向Perspective.createInitialLayout()添加额外代码: 但不显示视图。 我将breakpoint设置到perspective.createInitialLayout()中,发现它没有执行。 我的观点声明是: ApplicationWorkbenchAdvisor.GetInitialWindowPe
问题内容: 我无法使LibGDX日志记录在Android Studio中工作。首先,我认为我的问题与之前的问题相同,但是请确保我的应用程序在调试时进行了更新。 选项按钮上的测试操作已执行,但我无法显示调试日志。 问题答案: 默认日志级别为。为了进行调用,您必须先调用一次(可能是Game构造函数的第一行,以便可以轻松更改它)。
我有数据,我需要显示在3行与标题在Laravel刀片视图。我知道Laravel中有chunk方法来对数据进行分块并显示。但我想以不同的方式展示数据。 这是我的数据 下面是我想要输出数据的方式 我怎样才能做到这一点?
我正试图添加数据在我的回收视图从火炉。我有带名字的文件(级别级别编号)但没有显示我的活动这是代码: 主要活动水平: 公共类级别活动扩展AppCompat活动{ } 水平调整器 公共类级别适配器扩展了RecyclerView。适配器 }