私はコードのこの部分を実行しており、データを解析してカスタムベースアダプターに設定しようとしています。その後、リストをclcikableにしたい...
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ListActivity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class StreamPage extends ListActivity {
String UrlForStream;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.streampage);
RestImplimentationMethods urlretriver = new RestImplimentationMethods();
UrlForStream = urlretriver.GenerateFullUrlforStream(getIntent()
.getStringExtra("secret"));
ParsingForStream(UrlForStream);
Log.d("****Stream****URL", UrlForStream);
}
private void ParsingForStream(String urlForStream2) {
// TODO Auto-generated method stub
new LongOperation().execute(UrlForStream);
}
private class LongOperation extends AsyncTask<String, Void, String> implements OnItemClickListener {
private static final String TAG_streamable = "streamable";
private static final String TAG_Title = "title";
private static final String TAG_Description = "description";
private static final String TAG_Image = "image";
StreamPersingClass Spc;
JSONArray streamable = null;
ArrayList<StreamPersingClass> searchResultss = new ArrayList<StreamPersingClass>();
final ListView lv1 = getListView();
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
JSONParser jparser = new JSONParser();
JSONObject json = jparser.getJSONFromUrl(params[0]);
try {
streamable = json.getJSONArray(TAG_streamable);
for (int i = 0; i < streamable.length(); i++) {
Spc = new StreamPersingClass();
JSONObject c = streamable.getJSONObject(i);
Spc.setTitle(c.getString(TAG_Title));
Spc.setDescription(c.getString(TAG_Description));
Spc.setImage(c.getString(TAG_Image));
searchResultss.add(Spc);
Log.d("****Stream***Title***", Spc.getTitle());
Log.d("****Stream***Description***", Spc.getDescription());
Log.d("****Stream**Image Title****", Spc.getImage());
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
lv1.setAdapter(new MyCustomBaseAdapter(StreamPage.this,
searchResultss));
lv1.setOnItemClickListener(this);
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_LONG).show();
}
}
}
私は今何をしなければなりませんか?? 任意の提案.....うまく機能する非同期タスクがなかった別のコードを試しました...