0

我正在构建一个应用程序,该应用程序将显示来自我的 parse.com 应用程序的表/类“消息”中的列“NameMessage”中的值:单击“显示”按钮时调用:“ParseQueryAdapter”。单击显示按钮时没有任何反应,第二次单击显示按钮时应用程序崩溃。我还附上了logcat。请帮忙。谢谢

import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import com.parse.FindCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseQueryAdapter;



public class MainActivity extends Activity {
private ParseQueryAdapter<ParseObject> mainAdapter;
private ListView listView;
private EditText textName;
private EditText textMessage;
private Button buttonSendInfo;
public double plong;
public double plat;
private Button buttonDisplay;
 ArrayList<String> messagesarray = new ArrayList<String>();
 private ListView lv;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Parse.initialize(this, *HIDDEN FOR SAFETY*);



textName = (EditText)findViewById(R.id.editTextName);
textMessage = (EditText)findViewById(R.id.editTextMessage);
buttonSendInfo = (Button)findViewById(R.id.buttonSend);
buttonDisplay = (Button)findViewById(R.id.toggleButton);
buttonDisplay.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {

        populatelist();
        }
        }

protected void populatelist() {
lv = (ListView) findViewById(R.id.myList);
ParseQuery<ParseObject> query = ParseQuery.getQuery("Messages");
query.findInBackground(new FindCallback<ParseObject>(){

    @Override
    public void done(List<ParseObject> NameMessage, ParseException e) {
        if (e == null){
            for(int i = 0;i<NameMessage.size();i++){

                messagesarray.add(NameMessage.get(i).toString());




            }

        }
        else {Log.d("Messages","Error:"+e.getMessage());}

    }


    });

ListView list = (ListView) findViewById(R.id.myList);
        lv.setAdapter(new ArrayAdapter<String>(MainActivity.this,R.id.myList,R.layout.list_item,messagesarray));    
}

}

日志猫:

10-14 04:53:02.205: E/AndroidRuntime(912): android.content.res.Resources$NotFoundException: Resource ID #0x7f080007 type #0x12 is not valid 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2309) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.content.res.Resources.getLayout(Resources.java:934) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.LayoutInflater.inflate(LayoutInflater.java:395) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.AbsListView.obtainView(AbsListView.java:2177) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.ListView.makeAndAddView(ListView.java:1840) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.ListView.fillDown(ListView.java:675) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.ListView.fillFromTop(ListView.java:736) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.ListView.layoutChildren(ListView.java:1655) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.AbsListView.onLayout(AbsListView.java:2012) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.View.layout(View.java:14289) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewGroup.layout(ViewGroup.java:4559) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.View.layout(View.java:14289) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewGroup.layout(ViewGroup.java:4559) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.View.layout(View.java:14289) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewGroup.layout(ViewGroup.java:4559) 
10-14 04:53:02.205: E/AndroidRuntime(912): at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:349) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.View.layout(View.java:14289) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewGroup.layout(ViewGroup.java:4559) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.View.layout(View.java:14289) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewGroup.layout(ViewGroup.java:4559) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1976) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1730) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.Choreographer.doCallbacks(Choreographer.java:562) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.Choreographer.doFrame(Choreographer.java:532) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.os.Handler.handleCallback(Handler.java:730) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.os.Handler.dispatchMessage(Handler.java:92) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.os.Looper.loop(Looper.java:137) 
10-14 04:53:02.205: E/AndroidRuntime(912): at android.app.ActivityThread.main(ActivityThread.java:5103) 
10-14 04:53:02.205: E/AndroidRuntime(912): at java.lang.reflect.Method.invokeNative(Native Method) 
10-14 04:53:02.205: E/AndroidRuntime(912): at java.lang.reflect.Method.invoke(Method.java:525) 
10-14 04:53:02.205: E/AndroidRuntime(912): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
10-14 04:53:02.205: E/AndroidRuntime(912): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
10-14 04:53:02.205: E/AndroidRuntime(912): at dalvik.system.NativeStart.main(Native Method)

这是我的桌子的[屏幕截图][1]。

https://fbcdn-sphotos-ha.akamaihd.net/hphotos-ak-xpf1/v/t34.0-12/1958582_10152484345338178_1225744402895431728_n.jpg?oh=f5170a80b5336193a28f86ed1293268e&oe=543F72BC& gda =1413426615_2ae1ecb312ef73ff1dd20ee5d006d753

4

0 回答 0