0

我一直在寻找如何解决这个错误,但我没有任何运气。我有一个使用导航抽屉并使用自定义列表视图拉入片段的应用程序。我在即将到来的事件片段中的 ParseQueryAdapter 调用以及 EventsAdapter 调用中出现错误。

即将到来的事件.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);
}

事件适配器.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;
}
4

0 回答 0