Android 无法从parse.com检索数组
我在parse.com dashboard中创建了此数组列。我可以从我的应用程序在数组中添加值,但我无法获取数组或列表,并且使用iteven size上的任何函数在该行上给出空点异常 我使用了很多解决方案,但没有一个有效 我的代码出现了错误Android 无法从parse.com检索数组,android,arrays,parse-platform,Android,Arrays,Parse Platform,我在parse.com dashboard中创建了此数组列。我可以从我的应用程序在数组中添加值,但我无法获取数组或列表,并且使用iteven size上的任何函数在该行上给出空点异常 我使用了很多解决方案,但没有一个有效 我的代码出现了错误 real = (TextView) v.findViewById(R.id.realtext); fake = (TextView) v.findViewById(R.id.faketext); realbutton = (I
real = (TextView) v.findViewById(R.id.realtext);
fake = (TextView) v.findViewById(R.id.faketext);
realbutton = (ImageButton) v.findViewById(R.id.realbutton);
fakebutton = (ImageButton) v.findViewById(R.id.fakebutton);
real.setText(String.valueOf(news.getRealvote()));
fake.setText(String.valueOf(news.getFake()));
fakebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
news.setuserArray(news.getAuthor().getUsername());
List<ParseObject> a = news.getUserArray();
Toast.makeText(c, a.toString(), Toast.LENGTH_SHORT).show();//any thing with a.size() etc anything gives error
news.setFake();
news.saveInBackground();
fake.setText(String.valueOf(news.getFake()));
realbutton.setVisibility(View.GONE);
fakebutton.setVisibility(View.GONE);
}
});
我尝试了很多,但没有成功。plss帮助我检索阵列
你要的是列表适配器吗
public class Customnewslistview extends ParseQueryAdapter<News> {
Context c;
public Customnewslistview(Context context) {
super(context, "News");
c = context;
}
@Override
public View getItemView(final News news, View v, ViewGroup parent) {
if (v == null) {
final TextView real;
final TextView fake;
final ImageButton realbutton;
final ImageButton fakebutton;
final ProgressBar loader;
v = View.inflate(getContext(), R.layout.item_list_news_public, null);
loader = (ProgressBar) v.findViewById(R.id.eachnewsloder);
ParseImageView newsImage = (ParseImageView) v
.findViewById(R.id.icon);
ParseFile photoFile = news.getParseFile("photo");
if (photoFile != null) {
newsImage.setParseFile(photoFile);
newsImage.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
Log.d("done pic", data.toString());
loader.setVisibility(View.GONE);
}
});
} else {
loader.setVisibility(View.GONE);
newsImage.setBackgroundResource(R.drawable.image40);
}
TextView titleTextView = (TextView) v.findViewById(R.id.text1);
titleTextView.setText(news.getTitle());
// trying real fake buttons
real = (TextView) v.findViewById(R.id.realtext);
fake = (TextView) v.findViewById(R.id.faketext);
realbutton = (ImageButton) v.findViewById(R.id.realbutton);
fakebutton = (ImageButton) v.findViewById(R.id.fakebutton);
real.setText(String.valueOf(news.getRealvote()));
fake.setText(String.valueOf(news.getFake()));
realbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
news.setuserArray(news.getAuthor().toString());
news.setRealvote();
news.saveInBackground();
real.setText(String.valueOf(news.getRealvote()));
Toast.makeText(getContext(), "No Cheating",
Toast.LENGTH_SHORT).show();
realbutton.setVisibility(View.GONE);
fakebutton.setVisibility(View.GONE);
}
});
fakebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
news.setuserArray(news.getAuthor().getUsername());
List<ParseObject> a=null;
try {
a = news.fetchIfNeeded().getList("users_rated");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(c, a.toString(), Toast.LENGTH_SHORT).show();
news.setFake();
news.saveInBackground();
fake.setText(String.valueOf(news.getFake()));
realbutton.setVisibility(View.GONE);
fakebutton.setVisibility(View.GONE);
}
});
titleTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog d = new Dialog(c);
d.setContentView(R.layout.publicnewsdialog);
d.setTitle("News");
TextView text = (TextView) d.findViewById(R.id.dialogtext);
text.setText(news.getTitle());
// parsing image
ParseImageView newsImage = (ParseImageView) d
.findViewById(R.id.dialogimage);
ParseFile photoFile = news.getParseFile("photo");
if (photoFile != null) {
newsImage.setParseFile(photoFile);
newsImage.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
Log.d("done pic", data.toString());
}
});
} else {
loader.setVisibility(View.GONE);
newsImage.setBackgroundResource(R.drawable.image40);
}
d.show();
}
});
}
return v;
}
}
这是我用来获取TrackedLocation对象数据库列表的方法:
对将在“完成”回调中收到的ParseObject的数据列表执行所需操作。尝试news.fetchIfNedded.getUserArray;给出错误:致命异常:main 12-06 20:17:04.777:E/AndroidRuntime7569:java.lang.IllegalStateException:ParseObject没有此键的数据。需要调用fetchif来获取数据。12-06 20:17:04.777:E/AndroidRuntime7569:at com.parse.ParseObject.checkGetAccessParseObject.java:2793 12-06 20:17:04.777:E/AndroidRuntime7569:at com.parse.ParseObject.getStringParseObject.java:2351 12-06 20:17:04.777:E/AndroidRuntime7569:at com.parse.ParseUser.getUsernameParseUser.java:275显示getListString方法getListString来自parse.com apinahh..dat不起作用…它给了我一个具有该特定值的所有行的列表..但是这里我想要一个数组,它以不同的方式存储每一行..n我想要为适配器中的每一行提取该数组@Emil adz然后删除此行:query.whereequaltoimi,helpUtils.getDeviceideQualsimi;您将拥有此表中的最后1000个条目。
public void setuserArray(String file) {
addUnique("users_rated", file);
}
public class Customnewslistview extends ParseQueryAdapter<News> {
Context c;
public Customnewslistview(Context context) {
super(context, "News");
c = context;
}
@Override
public View getItemView(final News news, View v, ViewGroup parent) {
if (v == null) {
final TextView real;
final TextView fake;
final ImageButton realbutton;
final ImageButton fakebutton;
final ProgressBar loader;
v = View.inflate(getContext(), R.layout.item_list_news_public, null);
loader = (ProgressBar) v.findViewById(R.id.eachnewsloder);
ParseImageView newsImage = (ParseImageView) v
.findViewById(R.id.icon);
ParseFile photoFile = news.getParseFile("photo");
if (photoFile != null) {
newsImage.setParseFile(photoFile);
newsImage.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
Log.d("done pic", data.toString());
loader.setVisibility(View.GONE);
}
});
} else {
loader.setVisibility(View.GONE);
newsImage.setBackgroundResource(R.drawable.image40);
}
TextView titleTextView = (TextView) v.findViewById(R.id.text1);
titleTextView.setText(news.getTitle());
// trying real fake buttons
real = (TextView) v.findViewById(R.id.realtext);
fake = (TextView) v.findViewById(R.id.faketext);
realbutton = (ImageButton) v.findViewById(R.id.realbutton);
fakebutton = (ImageButton) v.findViewById(R.id.fakebutton);
real.setText(String.valueOf(news.getRealvote()));
fake.setText(String.valueOf(news.getFake()));
realbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
news.setuserArray(news.getAuthor().toString());
news.setRealvote();
news.saveInBackground();
real.setText(String.valueOf(news.getRealvote()));
Toast.makeText(getContext(), "No Cheating",
Toast.LENGTH_SHORT).show();
realbutton.setVisibility(View.GONE);
fakebutton.setVisibility(View.GONE);
}
});
fakebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
news.setuserArray(news.getAuthor().getUsername());
List<ParseObject> a=null;
try {
a = news.fetchIfNeeded().getList("users_rated");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Toast.makeText(c, a.toString(), Toast.LENGTH_SHORT).show();
news.setFake();
news.saveInBackground();
fake.setText(String.valueOf(news.getFake()));
realbutton.setVisibility(View.GONE);
fakebutton.setVisibility(View.GONE);
}
});
titleTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog d = new Dialog(c);
d.setContentView(R.layout.publicnewsdialog);
d.setTitle("News");
TextView text = (TextView) d.findViewById(R.id.dialogtext);
text.setText(news.getTitle());
// parsing image
ParseImageView newsImage = (ParseImageView) d
.findViewById(R.id.dialogimage);
ParseFile photoFile = news.getParseFile("photo");
if (photoFile != null) {
newsImage.setParseFile(photoFile);
newsImage.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
Log.d("done pic", data.toString());
}
});
} else {
loader.setVisibility(View.GONE);
newsImage.setBackgroundResource(R.drawable.image40);
}
d.show();
}
});
}
return v;
}
}
ParseQuery<ParseObject> query = ParseQuery.getQuery("TrackedLocation");
query.whereEqualTo("imei", helpUtils.getDeviceIDEqualsIMEI());
query.setLimit(1000);
query.findInBackground(new FindCallback<ParseObject>()
{
@Override
public void done(List<ParseObject> dataList, ParseException e) {}
});