このエラーを修正する方法をしばらく探していましたが、運がありませんでした。ナビゲーション ドロワーを使用し、カスタム リスト ビューでフラグメントを取り込むアプリがあります。Upcoming Events Fragment の ParseQueryAdapter 呼び出しと EventsAdapter 呼び出しでエラーが発生しました。
UpcomingEvents.java
public class UpcomingEvents extends Fragment {
View myView;
private ParseQueryAdapter<Event> mainAdapter;
private EventsAdapter eventAdapter;
private ListView listView;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstaceState) {
myView = inflater.inflate(R.layout.upcoming_events, container, false);
mainAdapter = new ParseQueryAdapter<Event>(this, Event.class);
mainAdapter.setImageKey("Image");
mainAdapter.setTextKey("Link");
mainAdapter.setTextKey("Location");
mainAdapter.setTextKey("Time");
mainAdapter.setTextKey("Title");
eventAdapter = new EventsAdapter(this);
listView = (ListView)myView.findViewById(R.id.eventsList);
listView.setAdapter(mainAdapter);
mainAdapter.loadObjects();
return myView;
}
イベント.java
@ParseClassName("Event")
public class Event extends ParseObject{
public Event(){}
public ParseFile getImageFile(){
return getParseFile("Image");
}
public void setImageFile(ParseFile file){
put("Image", file);
}
public String getLink(){
return getString("Link");
}
public void setLink(String link){
put("Link", link);
}
public String getLocation(){
return getString("Location");
}
public void setLocation(String location){
put("Location", location);
}
public String getTime(){
return getString("Time");
}
public void setTime(String time){
put("Time", time);
}
public String getEventTitle(){
return getString("Title");
}
public void setEventTitle(String title){
put("Title", title);
}
EventsAdapter.java
public class EventsAdapter extends ParseQueryAdapter<Event> {
ParseImageView flyer;
TextView title, date;
Button ticket;
String link;
public EventsAdapter(Context context) {
super(context, new ParseQueryAdapter.QueryFactory<Event>() {
public ParseQuery create() {
ParseQuery query = new ParseQuery("Event");
query.orderByDescending("createdAt");
return query;
}
});
}
@Override
public View getItemView(Event event, View v, ViewGroup parent) {
if (v == null) {
v = View.inflate(getContext(), R.layout.eventlist_item, null);
}
super.getItemView(event, v, parent);
flyer = (ParseImageView) v.findViewById(R.id.flyer);
ParseFile imageFile = event.getImageFile();
if (imageFile != null) {
flyer.setParseFile(imageFile);
flyer.loadInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
}
});
}
title = (TextView) v.findViewById(R.id.title);
title.setText(event.getEventTitle());
date = (TextView) v.findViewById(R.id.date);
date.setText(event.getTime());
ticket = (Button) v.findViewById(R.id.ticket);
link = event.getLink();
ticket.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse(link));
//startActivity(i);
}
});
return v;
}