English 中文(简体)
封条
原标题:Android Check if banner is pressed

我试图找到一种办法,检查一个旗帜(ad)是否受到检查,但更难以控制。

审判

adView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //TODO
        }
    });

但是,它不做工作(一只字不提,但做的是工作)。

然后,我试图制造一条线性语言,总结意见,将听众排在线性布局上,但还是没有工作。

然后,我试图创造更大的布局,包含所有显示物,并在其中添加“意见”。 我想把TouchListener放到这里,并检查坐标,以检查该添加剂是否受到压力。 但是,我并不真正理解如何找到我旗帜的正确坐标(即制造一种获得X和 y被抵消的方法,以及用重力打旗子),以检查,而且确实希望有更好的办法。 此外,我还发现,如果一只新闻旗帜,这种方法就没有执行,而只是在屏幕的其他部分受到压力的情况下。

因此,是否有办法知道? 我并不想知道,旗帜页是否装满,或者它是否转往市场或浏览器,而只是需要知道该旗帜是否被封。

Maybe setting a check that runs when the screen is touched, and than check if the listner method was run, and if it wasn t run that the banner was touched can work, but i don t know how to implement it..

任何如何这样做的想法?

谢谢。

问题回答

I don t know why other people haven t spoken about which adView you are using? Most (like in all I know) provide a listener you can supply, that has a callback for when a ad is clicked.

例如,MobFox有set BannerListener(BannerListener),该听众有一套方法adClicked(。 其他提供方(如 ad、 in、 mo)也拥有类似的听众。

这应当成为处理该问题的办法,而不是冲入集装箱。

对于那些仍然执着的人来说,如何:

其使用

adView.setAdListener(new AdListener() {
            public void onDismissScreen(Ad arg0) {
               Toast.makeText(BannerAdListener.this, "Back to app", Toast.LENGTH_SHORT).show();
            }

            public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
               Toast.makeText(BannerAdListener.this, "Error loading", Toast.LENGTH_SHORT).show();

            }

            public void onLeaveApplication(Ad arg0) {
               Toast.makeText(BannerAdListener.this, "Left app", Toast.LENGTH_SHORT).show();

            }

            public void onPresentScreen(Ad arg0) {
               Toast.makeText(BannerAdListener.this, "Sumthin sumthin", Toast.LENGTH_SHORT).show();

            }

            public void onReceiveAd(Ad arg0) {
               Toast.makeText(BannerAdListener.this, "Ad Received", Toast.LENGTH_SHORT).show();

            }
            });

你们是否试图在你点击活动中打一名牙?

Does the app compile and run?

是否有重复女胎?

奥基,我解决了这个问题,因为我失去了寻找解决办法的很多时间,而把解决办法放在这里,使每个人都能找到和使用它!

LinearLayout containAdView = null;

    if(registerTouch)
    {
            containAdView = new LinearLayout(pActivity){

            public boolean onInterceptTouchEvent(MotionEvent ev)
            {
                if(ev.getAction() == MotionEvent.ACTION_UP)
                {
                    bannerClicked(pActivity, shared_Prefs_name, shared_Save_name);

                    if(mainMenu.ISDEV)
                    {
                        final Toast tost = Toast.makeText(pActivity, "Banner Clicked", Toast.LENGTH_SHORT);
                        tost.show();
                    }
                }

                return super.onInterceptTouchEvent(ev);
            }
        };
        containAdView.addView(adView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
    }




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签