我有以下按钮
<asp:ImageButton ID="button1" runat="server"
ImageUrl="~/image.jpg"
CommandName = "id"
CommandArgument = "1"
onclick="button1_Click"
/>
Run Code Online (Sandbox Code Playgroud)
并在代码背后
protected void button1_Click(object sender, ImageClickEventArgs e)
{
Response.Write(e.commandName);
}
Run Code Online (Sandbox Code Playgroud)
这不起作用!!,所以我的问题是如何从按钮控制获得价值?
我知道我可以获得一个图像按钮的X和Y,但我如何获得它的ID?
我想先从打印到标签开始.后来我想在一个切换案例中使用它 - 任何不同的情况都会将imagebutton.imageurl更改为不同的图像,但特别是我刚刚点击的图像按钮.
我试过了
Label1.Text = Convert.ToString((ImageButton)sender);
Run Code Online (Sandbox Code Playgroud)
但这就是结果
System.Web.UI.WebControls.ImageButton
Run Code Online (Sandbox Code Playgroud)
因此我没有太多帮助,因为我需要特定控件的ID.
谢谢!
我有一个<asp:ImageButton />已经其enabled属性设置为false.
这适用于Internet Explorer,该按钮不是"可点击",但在其他浏览器中,您可以单击它.但是,单击imagebutton这些其他浏览器时没有任何反应.
如何禁用在Internet Explorer外部的浏览器中单击按钮的功能?
swing几天以来,我一直在研究开发gui应用程序.
以下代码旨在创建一个带退出按钮的工具栏(包括图像 "exit.png").问题是虽然工具栏显示,但我无法看到图像.该工具栏的位置使用的borderlayout经理在java中.NORTH
JMenuBar menubar = new JMenuBar();
JMenu file = new JMenu("File");
menubar.add(file);
setJMenuBar(menubar);
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
ImageIcon exit = new ImageIcon("exit.png");
JButton bexit = new JButton(exit);
bexit.setBorder(new EmptyBorder(0, 0, 0, 0));
toolbar.add(bexit);
//Default layout manager for JFrame is BorderLayout Manager
add(toolbar, BorderLayout.NORTH);
Run Code Online (Sandbox Code Playgroud)
代码写在类构造函数中,类扩展了JFrameswing类.
请注意我已导入所需的课程.也没有编译错误.图像保存在创建.class的目录中.显示gui的其他元素没有错误.
请帮我确定问题所在.提前致谢.
我有一个很酷的图像(花哨的圆角)。我想在我的android应用程序中实现该图像。当我单击它时,我希望它变暗一点(就像按下时的按钮一样)并启动新的活动。
我该怎么办?应该使用什么(ImageView,ImageButton或Button)?
我正在动态地将图像加载到屏幕上的图像按钮上.图像将不会提前知道并且是差异大小.
有谁知道如何确保图像按钮大小保持不变,无论分配给它的图像是什么.优选地拉伸图像以适合按钮.我已经尝试使用android:scaleType ="fitXY"并将ewidth和height设置为硬值(不是更可取).无论我做什么,图像都决定了按钮的大小,反之亦然!救命!
我尝试了以下的组合.这些图像是从互联网搜索中随机出现的.
<ImageButton
android:id="@+id/ImageButton1"
android:layout_height="93px"
android:src="@drawable/image1"
android:layout_width="93px"
android:background="93px" />
<ImageButton
android:id="@+id/ImageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/image1"
android:scaleType="fitXY" />
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助!
我正在使用按钮(或ImageButtons)来显示我的应用程序的图标.我使用它来设置按钮的状态,按下按钮的图像和按下按钮的另一个图像:
selector(this, favorites, R.drawable.icon_star_mark, R.drawable.icon_star_mark_selected);
public static void selector(Context c, Button b, int normal_image, int pressed_image){
StateListDrawable states = new StateListDrawable();
states.addState(new int[] {android.R.attr.state_pressed}, c.getResources().getDrawable(pressed_image));
states.addState(new int[] { }, c.getResources().getDrawable(normal_image));
b.setBackgroundDrawable(states);
}
Run Code Online (Sandbox Code Playgroud)
我需要将文本放在图标下方,但我想学习它而不使用带有图标和文本视图的LinearLayout.如果有可能实现它,我想学习这样做.
这是我创建图标的方式:
Button map= new Button(this);
selector(this, map, R.drawable.icon_map, R.drawable.icon_map_selected);
map.setText("Map");
Run Code Online (Sandbox Code Playgroud)
问题是文本显示在图标上方,而不是图标下方.
使用java代码可以实现这一点吗?(将图标文本放在图标下方,而不使用图标下方带有textview的线性布局)
提前致谢
我正在使用一些Acitivity,它工作得很好.但我有一个奇怪的延迟.
我想通了,这是关于代码的这一部分,我在SDCard中加载存储的图像.
if(p.getAdress() != null){
Bitmap bitmap = BitmapFactory.decodeFile(p.getAdress());
new_image.setBackgroundDrawable(null);
new_image.setImageBitmap(bitmap);
}
Run Code Online (Sandbox Code Playgroud)
为什么这个简单的代码执行时间太长?
怎么解决?
如果我取消这个代码,一切都按照我的意愿行事.
我需要在背景上设置背景颜色和图像,我该怎么办?图像必须具有透明度吗?我也需要控制状态:紧迫,专注.
任何帮助将不胜感激
我正在尝试升级以前使用的旧应用程序ActionBarSherlock。我想我已经用新东西代替了所有使用它的东西。目前,标题出现错误,这很奇怪,而且肯定很难修复。我已经在寻找修复程序并应用了每个修复程序,但仍然收到错误消息。我尝试使用,AppCompatImageButton但是当我这样做时,错误现在提示Error inflating class android.widget.AppCompatImageButton。错误日志如下。
FATAL EXCEPTION: main
Process: com.csipsimple, PID: 22863
android.view.InflateException: Binary XML file line #113: Binary XML file line #4: Error inflating class com.csipsimple.widgets.Dialpad
Caused by: android.view.InflateException: Binary XML file line #4: Error inflating class com.csipsimple.widgets.Dialpad
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(Unknown Source:194)
at android.view.LayoutInflater.createViewFromTag(Unknown Source:197)
at android.view.LayoutInflater.createViewFromTag(Unknown Source:6)
at android.view.LayoutInflater.rInflate(Unknown Source:101)
at android.view.LayoutInflater.parseInclude(Unknown Source:284)
at android.view.LayoutInflater.rInflate(Unknown Source:79)
at android.view.LayoutInflater.rInflateChildren(Unknown Source:9)
at android.view.LayoutInflater.inflate(Unknown Source:264)
at android.view.LayoutInflater.inflate(Unknown Source:20)
at …Run Code Online (Sandbox Code Playgroud)