Code example for ImageButton

Methods: setVisibility, setBackgroundResource, setLayoutParams, setOnClickListener

0
        adWapsArea.setGravity(LinearLayout.VERTICAL);
        adArea.addView(adWapsArea, adWapsAreaParams);
 
        // ���������رհ�ť 
        int rmAdid = ResourceUtil.getDrawableResourceIdFromName(context, "rm_ad");
        imageButton = new ImageButton(context);
        RelativeLayout.LayoutParams imageButtonParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        imageButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        imageButtonParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        imageButton.setBackgroundResource(rmAdid);
        imageButton.setVisibility(View.GONE);
        imageButton.setLayoutParams(imageButtonParams);
 
        adArea.addView(imageButton);
 
        activity.addContentView(adArea, adAreaParams);
        new AdView(activity, adWapsArea).DisplayAd();
 
        // �Ƿ���ʾ�����رհ�ť 
        isShowAdCloseButtom(); 
        // ָ���û�ȥ���ѹرջ��������� 
        warnUserSpendForCloseAd(); 
    } 
 
    /** 
     * ��ʾ�û��رջ���������Ҫ����һ���Ļ��� 
     */ 
    private static void warnUserSpendForCloseAd() { 
 
        // ���ӹرհ�ť�ĵ����¼��ļ��� 
        imageButton.setOnClickListener(new View.OnClickListener() { 
            @Override 
            public void onClick(View view) { 
                int userPoints = getUserPointsFromLocal(); 
                final int spendPoints = 80;