1
返回錯誤的數據你好我使用avocarrot SDK原生廣告。我已經在我的列表視圖&中成功實現了廣告展示效果非常好。但是當我點擊listview使用setOnClickListener我得到錯誤的數據。下面是我的代碼..列表視圖setOnClickListener從列表視圖
avocarrot setlistadapter
avocarrotInstream = new com.avocarrot.androidsdk.AvocarrotInstream(
listAdapter, /* pass your listAdapter */
this, /* reference to your Activity */
"my api key", /* replace with your Avocarrot API Key */
"my placement key" /* replace with your Avocarrot Placement Key */
);
avocarrotInstream.setLogger(true, "ALL");
avocarrotInstream.setSandbox(true);
avocarrotInstream.setLayout(R.layout.avocarrot_feed_row, R.id.avo_container, R.id.feed_title, R.id.feed_description, R.id.feed_icon, R.id.feed_image, R.id.feed_button);
// Bind the created avocarrotInstream adapter to your list instead of your listAdapter
listView.setAdapter(avocarrotInstream);
我onclicklistener
private class Click2 implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Object obj = avocarrotInstream.getItem(position);
String name = ((TextView) view.findViewById(R.id.name)).getText()
.toString();
String status = ((TextView) view.findViewById(R.id.txtStatusMsg))
.getText().toString();
String bitmap = ((FeedItem) feedItems.get(position)).getImge();
Intent in = new Intent(NewBlogStyleHindi.this, SingleActivity.class);
in.setType("text/html");
in.putExtra(TAG_TITLE, name);
in.putExtra("images", bitmap);
in.putExtra(TAG_TEXT, status);
startActivity(in);
}
}
和avocarrot只要列表視圖setonclicklistener作爲
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
/* get your object from avocarrotInstream for clicked position */
Object obj = avocarrotInstream.getItem(position);
}
});
由於廣告排在增加..
() );'? –
那是我在用,但由於原生廣告排增加,所以我得到的數據一個列表項back..if有在整個飼料數據的兩個廣告,然後我回去使用setOnClickListener 2個列表項數據,你能告訴我如何訪問列表視圖數據使用此行 Object obj = avocarrotInstream.getItem(position); –
該行有錯誤嗎?我不明白爲什麼這是行不通的。 –