我构建的图像按钮有问题。当我将所需的字段验证器附加到页面时,它们会阻止按钮 onclick 事件触发。我对此感到非常困惑,因为我在我的代码中看不到任何问题!
请你能把目光投向这个并帮助我吗?
干杯
<asp:TextBox ID="TB_Newsletter" runat="server" CssClass="nwsltr-input"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="V1" runat="server" Display="Dynamic" ControlToValidate="TB_Newsletter" ErrorMessage="You must enter your email address"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ValidationGroup="V1" Display="Dynamic"
ValidationExpression="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
ErrorMessage="Invalid Email Address" ControlToValidate="TB_Newsletter"></asp:RegularExpressionValidator>
<asp:ImageButton ID="IB_SubScri"
ImageUrl="~/_includes/images/buttons/nwsltr-btn.png" runat="server"
onclick="IB_SubScri_Click" CausesValidation="True" ValidationGroup="V1"/>
Run Code Online (Sandbox Code Playgroud) 制作 Winforms ImageButton 类 (C#) 时遇到了一些麻烦。我的 ImageButton 类实现了 IButtonControl 接口,但是当我将其添加到窗体中,并将按钮的 DialogResult 设置为 'OK' ,然后在窗体上调用 ShowDialog() 时,按下按钮不会关闭窗体并返回 DialogResult,如正常的 Winforms 按钮控件可以。
这是我对 ImageButton 的实现,您可以随意使用它。
/// <summary>
/// A control that displays an image and responds to mouse clicks on the image.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[Designer(typeof(ImageButtonDesigner))]
[ToolboxItem(typeof(ImageButtonToolboxItem))]
public class ImageButton : PictureBox, IButtonControl, INotifyPropertyChanged
{
#region Constructors
/// <summary>
/// Initializes a new instance of the ImageButton class using the default initial values.
/// </summary>
public ImageButton()
{
DoubleBuffered = …Run Code Online (Sandbox Code Playgroud) 我必须以编程方式创建几个按钮图像按钮,但我不知道如何更改它们的大小。左右改变不起作用。
我在 xml 文件中有一个 imageButton。现在想让它成为一个菜单按钮,这样当用户点击按钮时,它应该显示下拉菜单。但我无法弄清楚可能的解决方案是什么。任何人都可以帮忙吗?
我正在ASP.NET中创建一个常规库,但我没有创建缩略图的经验.我知道算法和GetThumbnailImage方法,但我的问题是在其他地方 - 我正在使用ImageButton控件显示图像(刚刚调整大小).这就是重点 - 我不知道如何将"缩略图"图像连接到ImageUrl属性.甚至是可能的,如果是的话,怎么样?或者我应该使用其他控件吗?谢谢你的任何建议!
如何在我的窗口小部件中有一个图像,然后当它的点击更改为另一个图像?它只是一个只有一个ImageButton的小部件,但是我不知道在这之后去哪里,我知道所有关于待定意图等等,但这在这里没有用,除非我遗漏了什么......这是我的onUpdate
public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
PendingIntent onPendingIntent = PendingIntent.getService(context, 0, new Intent(context, widgetService.class), 0);
remoteViews.setOnClickPendingIntent(R.id.ImageButton01, onPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个图像按钮来关闭来自admob的广告.我在xml中创建了一个按钮,其visibility属性设置为"invisible",然后在java上我将广告设置为"可见",但按钮永远不会显示.如果我将它设置为"可见"硬编码在XML上,它通常会出现在屏幕上.
Admob布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layout_main">
<ImageButton
android:id="@+id/close_ad"
android:visibility="invisible"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-36dip"
android:layout_marginTop="12dip"
android:background="@drawable/btn_close_ad" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
添加广告:
private void addAd() {
rl = (RelativeLayout) activity.getLayoutInflater().inflate(R.layout.admob, null);
rl.setGravity(position);
activity.addContentView(rl, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
AdView admobView = new AdView(activity, AdSize.BANNER, Preferences.getAdmobKey());
admobView.loadAd(new AdRequest());
[ ... ]
admobView.setAdListener(new AdListener() {
@Override
public void onReceiveAd(Ad ad) {
Log.v("JeraAdmob", "onReceiveAd");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
createCloseButton();
}
}, AD_SHOW_CLOSE);
}
});
}
Run Code Online (Sandbox Code Playgroud)
创建按钮以关闭广告:
private void createCloseButton() {
ImageButton button …Run Code Online (Sandbox Code Playgroud) 我一直在寻找一个答案,但我找不到适合我的答案.我想在线性布局中将三张图片放在同一行中.我希望它们是ImageButtons,这是我的代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/ImageButton05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="@drawable/background" />
<ImageButton
android:id="@+id/ImageButton04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="@drawable/background" />
<ImageButton
android:id="@+id/ImageButton03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="centerInside"
android:src="@drawable/background" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我得到的问题是,由于图片"背景"太大,按钮的重量显示正确,而高度比预期的要大很多.它看起来像这样:
看起来像http://imageshack.us/a/img18/1516/x3qi.png
它看起来应该是这样的:
应该看看http://imageshack.us/a/img855/834/403t.png
如何在不指定dp大小的情况下解决这个问题?
我有这个使用服务激活的覆盖按钮.所以它是一个背景按钮.即使其他程序正在运行,您也可以看到该按钮.但是我在按钮上添加功能时遇到问题,当我按住它时,我可以将它拖到我想要的任何地方到屏幕上.我在这里检查了一些拖放选项,但我无法在我的程序中正确应用它.
在我的dragDrop()方法上,由于以下强制转换错误,它不起作用:
error(WindowManagerLayoutParams could not be cast on Freamelayout.LayoutParams)..
这是我的服务代码:
public class MainPowerAndVolumeService extends Service {
private ViewGroup mView;
private LayoutInflater inflater;
private ImageButton mainButton;
private Button testButton;
@Override
public IBinder
onBind(Intent intent) {
return null;
}
public void onCreate( ) {
super.onCreate();
/*This will make your window or layout to be overlay and of course you can click the buttons*/
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT
);
/*This will …Run Code Online (Sandbox Code Playgroud) 尝试将可滚动导航栏添加到屏幕底部时出现两个错误.我以前从未见过这个错误,到目前为止我找到的答案似乎没有解决我遇到的问题.
error: No resource identifier found for attribute 'layout_alignParentCenter' in package 'android' home.xml /idg/res/layout line 298 Android AAPT Problem
error: No resource identifier found for attribute 'layout_alignParentCenter' in package 'android' home.xml /idg/res/layout line 361 Android AAPT Problem
Run Code Online (Sandbox Code Playgroud)
任何输入都非常感谢.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- The rest of your layout (TextView, ScrollView, etc) -->
</LinearLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp" …Run Code Online (Sandbox Code Playgroud) imagebutton ×10
android ×7
c# ×3
xml ×2
.net ×1
admob ×1
asp.net ×1
dialogresult ×1
eclipse ×1
image ×1
java ×1
menu ×1
modal-dialog ×1
resize ×1
thumbnails ×1
validation ×1
widget ×1
winforms ×1