ollidiemaus
- Forum posts: 2
Oct 19, 2011, 7:05:34 PM via Website
Oct 19, 2011 7:05:34 PM via Website
I just wanted to put ads in my current app.
so i followed the tutorial from their homepage : https://redmine.madvertise.me/projects/madapi/wiki/Android_SDK
Erverthing works fine excepting the Show the view and get callback events
I think i am doing something wrong...
I have created the BannerActivity.java with the following code:
Hope someone can help me.
so i followed the tutorial from their homepage : https://redmine.madvertise.me/projects/madapi/wiki/Android_SDK
Erverthing works fine excepting the Show the view and get callback events
I think i am doing something wrong...
I have created the BannerActivity.java with the following code:
1package de.ollidiemaus.thguniversal;
2
3import android.app.Activity;
4import android.content.Intent;
5import android.os.Bundle;
6import android.view.*;
7import android.widget.*;
8
9public class BannerActivity extends Activity implements MadViewCallbackListener {
10 /** Called when the activity is first created. */
11
12 @Override
13 public void onCreate(Bundle savedInstanceState) {
14 super.onCreate(savedInstanceState);
15
16 // set the layout
17 setContentView(R.layout.main);
18
19 // set the callback listener, to receive a message when an ad was loaded
20 MadView madView = (MadView) findViewById(R.id.madad);
21 madView.setMadViewCallbackListener(this);
22
23 // prepare the list adapter with some countries
24 String[] countries = new String[] { "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe",
25 "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", "Iceland", "India",
26 "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos" };
27 ListAdapter adapter = new ArrayAdapter<String>(this, R.layout.list_item, countries);
28
29 // get list reference from layout file for action and adapter settings
30 ListView listView = (ListView) findViewById(R.id.country_list);
31
32 // show a small popup, when an item is clicked
33 listView.setOnItemClickListener(new OnItemClickListener() {
34 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
35 Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
36 }
37 });
38
39 // add countries to athe list
40 listView.setAdapter(adapter);
41 }
42 @Override
43 public void onLoaded(boolean succeed, MadView madView) {
44 if (succeed) {
45 // ad loaded, set view visible
46 Log.d("YOUR_LOG_TAG", "Ad successfully loaded");
47 madView.setVisibility(View.VISIBLE);
48 } else {
49 // ad could not be loaded, set view to invisible
50 Log.w("YOUR_LOG_TAG", "Ad could not be loaded");
51 madView.setVisibility(View.INVISIBLE);
52 }
53 }
54 }
2
3import android.app.Activity;
4import android.content.Intent;
5import android.os.Bundle;
6import android.view.*;
7import android.widget.*;
8
9public class BannerActivity extends Activity implements MadViewCallbackListener {
10 /** Called when the activity is first created. */
11
12 @Override
13 public void onCreate(Bundle savedInstanceState) {
14 super.onCreate(savedInstanceState);
15
16 // set the layout
17 setContentView(R.layout.main);
18
19 // set the callback listener, to receive a message when an ad was loaded
20 MadView madView = (MadView) findViewById(R.id.madad);
21 madView.setMadViewCallbackListener(this);
22
23 // prepare the list adapter with some countries
24 String[] countries = new String[] { "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe",
25 "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", "Iceland", "India",
26 "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos" };
27 ListAdapter adapter = new ArrayAdapter<String>(this, R.layout.list_item, countries);
28
29 // get list reference from layout file for action and adapter settings
30 ListView listView = (ListView) findViewById(R.id.country_list);
31
32 // show a small popup, when an item is clicked
33 listView.setOnItemClickListener(new OnItemClickListener() {
34 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
35 Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
36 }
37 });
38
39 // add countries to athe list
40 listView.setAdapter(adapter);
41 }
42 @Override
43 public void onLoaded(boolean succeed, MadView madView) {
44 if (succeed) {
45 // ad loaded, set view visible
46 Log.d("YOUR_LOG_TAG", "Ad successfully loaded");
47 madView.setVisibility(View.VISIBLE);
48 } else {
49 // ad could not be loaded, set view to invisible
50 Log.w("YOUR_LOG_TAG", "Ad could not be loaded");
51 madView.setVisibility(View.INVISIBLE);
52 }
53 }
54 }
Hope someone can help me.
— modified on Oct 20, 2011, 1:43:19 PM