我在我的应用程序中使用this框架。
所以我必须按下喜欢和不喜欢,我的代码就是这样:
public class JSONParse extends AsyncTask<String, String, JSONObject> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected JSONObject doInBackground(String... args) {
JSONParser jParser = new JSONParser();
url = "http://22.11.23.14/";
JSONObject json = jParser.getJSONFromUrl(url);
return json;
}
@Override
protected void onPostExecute(JSONObject json) {
try {
r = getResources();
String hakki;
adapter = new SimpleCardStackAdapter(getApplicationContext());
// Getting JSON Array
user = json.getJSONArray(TAG_OS);
for (int i = 0; i < user.length(); i++) {
final JSONObject c = user.getJSONObject(i);
// Storing JSON item in a Variable
String name = c.getString(username);
String email = c.getString(text);
String image1 = c.getString(imageUrl);
String msgId = c.getString(postId);
// adapter.add(new CardModel(name, email, image1));
card = new CardModel(name, email, image1);
//Set JSON Data in TextView
Log.i("image1image1image1image1", image1);
// CardModel cardModel = new CardModel(" cardModel", " CardModel", r.getDrawable(R.drawable.picture1));
card.setOnClickListener(new CardModel.OnClickListener() {
@Override
public void OnClickListener() {
Log.i("Swipeable Cards", "I am pressing the card");
}
});
card.setOnCardDimissedListener(new CardModel.OnCardDimissedListener() {
@Override
public void onLike() {
Log.i("Swipeable Cards", "I dislike the card");
}
@Override
public void onDislike() {
Log.i("Swipeable Cards", "I like the card");
new sendsendsendMethod().execute(sharedToken, "msgId");
}
});
adapter.add(card);
mCardContainer.setAdapter(adapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
1。我想获得适配器项目信息。在这一行:
String msgId = c.getString(postId);
我为每个帖子获得postId。如何在每次点击时调用此msgId?我需要添加适配器吗?如果我添加适配器如何调用适配器项信息?
2。我在这个适配器外面有两个按钮,一个用于喜欢,另一个用于不喜欢。如何为活动项目调用喜欢/不喜欢?
我希望我能解释一下自己。这个问题我差不多有3天了。其实我不能......
感谢