I have list view with Adapter class. i need show Startapp.com Interstitial Ads every 5th position clicked in list view, how? I just post sample codes here this is not a full code..
MainActivity.java
public class Search extends Activity implements OnItemClickListener,
OnScrollListener {
private StartAppAd startAppAd = new StartAppAd(this);
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
StartAppSDK.init(this, "xxxxxx", "xxxxxx", true);
listView = (ListView) findViewById(R.id.listview);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
footer = (View) inflater.inflate(R.layout.footer, null);
listView.addFooterView(footer);
objAdapter = new NewsRowAdapter(Latest.this, R.layout.row,
mainArrayList);
listView.setAdapter(objAdapter);
listView.setOnScrollListener(this);
listView.setOnItemClickListener(this);
if (Utils.isNetworkAvailable(Latest.this)) {
task = new MyTask();
task.execute(feed);
} else {
showToast("No Network Connection!!!");
}
}
NewsRowAdapter.java
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder holder;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(row, null);
holder = new ViewHolder();
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
if ((items == null) || ((position + 1) > items.size()))
return view;
objBean = items.get(position);
holder.tvTitle = (TextView) view.findViewById(R.id.title);
if (holder.tvTitle != null && null != objBean.getTitle()
&& objBean.getTitle().trim().length() > 0) {
holder.tvTitle.setText(Html.fromHtml(objBean.getTitle()));
}
if (position % 5 == 0) {
//HOW CAN I ADD STARTAPP ADS HERE
}
return view;
}
check position on item click and try this
hope this will help you