나는 어떻게해야하는지 뒤에있는 논리를 생각하려고합니다. 내가 지금하고있는 방식은 일종의 해킹이지만 작동한다. 그것은 너무 많은 API 요청과 불필요한 것입니다. 그래서 여기 누군가가 내가 어떻게해야하는지에 대해 상상하는 것을 도울 수 있습니다.데이터 가져 오기 및 textview 전달
저는 안드로이드 용 parse.com SDK를 사용하여 비디오를 표시하기위한 데이터를 검색하고 있습니다.
다음은이 수를 증가, 비디오 기능
int count = 9;
private void getVideos()
{
ParseQuery<ParseObject> query = ParseQuery.getQuery("Videos");
query.whereEqualTo("videoid", count);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> videoData, ParseException e) {
if (e == null) {
/** check to see if there are any more videos **/
if(videoData.size() == 0){
Toast.makeText(getApplicationContext(), "No more videos found.", Toast.LENGTH_LONG).show();
}else{
for(int i=0; i<videoData.size(); i++){
String videoUrl = videoData.get(i).getString("url");
String videoTitle = videoData.get(i).getString("title");
String videoUser = videoData.get(i).getString("user");
TextView title = (TextView)findViewById(R.id.videoTitle);
title.setTextColor(Color.parseColor("#FFFFFF"));
title.setText(videoTitle);
TextView user = (TextView)findViewById(R.id.videoUser);
user.setTextColor(Color.parseColor("#FFFFFF"));
user.setText("By: " + videoUser);
myVideoView = (VideoView) findViewById(R.id.myvideoview);
myVideoView.setVideoPath(vineVideoUrl);
myVideoView.setMediaController(null);
myVideoView.start();
/** loop video **/
myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
myVideoView.start();
}
});
/** next video **/
Button button= (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
count++;
Toast.makeText(getApplicationContext(), "Loading...", Toast.LENGTH_LONG).show();
getVideos();
}
});
}
}
} else {
Toast.makeText(getApplicationContext(), "Unable to retrieve videos, please check back later.", Toast.LENGTH_LONG).show();
}
}
});
}
버튼을 누를 때마다 내 코드이며, API에서 해당 ID에 대한 비디오를 가져옵니다. 내가 알아 내려고하는 것은 API에서 최신 20 개의 동영상이 올바른 방법으로 검색되도록하려면 어떻게해야합니까? 내가 할 수있는 적절한 방법을 생각할 수
방법은 이것이다 :
버튼을 각 통해 루프를 누르면 다음 API에서 최신 (20 개) 비디오, 배열에 저장을 가져옵니다. 어떻게하면 각각을 텍스트 뷰로 전달할 수 있습니까? 마지막 비디오가 언제인지 (20), API를 다시 호출하여 새로운 결과를 되돌려 놓아야합니다.