当以编程方式更改微调器选择时,以及当用户物理单击微调器控件时,都会调用OnItemSelectedListener事件处理程序.是否可以确定某个事件是否由用户选择以某种方式触发?
或者是否有另一种方法来处理微调器用户选择?
我使用android:theme ="@ android:style/Theme.Dialog"创建了一个非最大化的活动,使它看起来像一个对话框.我需要在屏幕上更改活动的位置,但我没有找到如何做到这一点......
如何解析动态字符串值以创建URL实例?我需要用空格%20,重音符号,非ASCII字符替换空格......?
我尝试使用,URLEncoder但它也编码/字符,如果我给URLEncoderURL构造函数编码一个字符串,我得到一个MalformedURLException(没有协议).
How can I change the first visible item in a list view (I searched a method such as setFirstVisiblePosition) ?
我有我自己的自定义库apk文件(比如lib.apk)&我想让它可用于其他应用程序.如何在其他应用程序的android manifest.xml文件中提供uses-library,以便使用我的自定义库.
我需要在mapview中添加自定义标记.第一个问题:我可以使用标准/默认覆盖/标记吗?第二:如果我要为标记叠加创建一个png,这是图像的最佳尺寸?我是否必须为每种屏幕尺寸(ldpi,mdpi,hdpi)创建不同的图像?
在我的应用程序中,当我单击EditText视图时,虚拟键盘会遮挡视图,因此我无法看到我的编辑内容.我该如何以编程方式解决此问题?
我需要在位图中绘制组件及其所有子组件的内容.如果我想绘制整个组件,以下代码可以正常工作:
public void printComponent(Component c, String format, String filename) throws IOException {
// Create a renderable image with the same width and height as the component
BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
// Render the component and all its sub components
c.paintAll(image.getGraphics());
// Render the component and ignoring its sub components
c.paint(image.getGraphics());
// Save the image out to file
ImageIO.write(image, format, new File(filename));
Run Code Online (Sandbox Code Playgroud)
}
但我没有找到一种只绘制该组件区域的方法.任何的想法 ?
似乎装有ImageIO.read的PNG忽略了alpha通道.(我试过JRE 6更新20)
错误?
示例:
public class Test extends JFrame
{
public Test()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton b = new JButton("Test");
try
{
b.setIcon(new ImageIcon(ImageIO.read(new File("D:\\image.png"))));
}
catch (IOException e2)
{
}
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
}
});
getContentPane().add(b, BorderLayout.CENTER);
setSize(500,500);
setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args)
{
new Test();
}
Run Code Online (Sandbox Code Playgroud)
}