小编Goo*_*ofy的帖子

如何在类之间共享变量?

假设我正在做类似测验的事情,我有一个计数器来显示已正确回答的问题数量.当一个问题得到正确回答,并显示一个新屏幕(活动)时,如何将该号码转移到下一个屏幕?

java variables android android-2.2-froyo

1
推荐指数
1
解决办法
4639
查看次数

我该如何实现条形图

我想在Android应用程序中使用一些适合的免费图表引擎显示条形图.这就是我对图表的看法:

我正在尝试使用以下功能.

添加onclick到每个栏(红色,蓝色,绿色).

在顶部而不是底部显示图例.

在Y轴上,它显示我想要显示的值1 - 200.

并且onlick显示每个栏顶部的值.

在此输入图像描述

我已经调查过,Achart engine但它没有像这样的条形图.

请帮帮我.

charts android bar-chart achartengine

1
推荐指数
1
解决办法
2274
查看次数

写入'n'个文件时,ByteArrayOutputStream中出现OutOfMemory错误

我正在将PDF写入SD卡并使用以下代码:

byte[] data = new byte[20000];
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
InputStream fileInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);

while ((nRead = fileInputStream.read(data, 0, data.length)) != -1) {
    buffer.write(data, 0, nRead);
}

buffer.flush();
byte[] bytesToWrite = buffer.toByteArray();
fileInputStream.read(bytesToWrite);
fileInputStream.close();

FileOutputStream fileOutputStream = null;
String outputFileName = outputDirName + "/" + fileName;
fileOutputStream = new FileOutputStream(outputFileName);
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
bos.write(bytesToWrite);
bos.flush();
bos.close();
Run Code Online (Sandbox Code Playgroud)

如果我试图一次写20个PDF,它工作正常,但如果它超过它,它给了我OutOfMemory错误.

可能是什么问题?

android out-of-memory

1
推荐指数
1
解决办法
2594
查看次数

全屏显示图像

我正在开发Windows Phone 8 app并在XAML中拥有这样的Image视图:

<Image Name="Image"
       Grid.Row="0"
       Visibility="Collapsed"
       Width="Auto"
       Height="Auto"
       Tap="Image_tap"
       HorizontalAlignment="Center"
       VerticalAlignment="Center"
       Margin="1,1,1,1"/>
Run Code Online (Sandbox Code Playgroud)

现在我有这个事件叫Tap="Image_tap",当我点击图像我想要全屏显示相同的图像,顶部和底部没有任何栏,如何实现这一点?

c# wpf fullscreen windows-phone windows-phone-8

1
推荐指数
2
解决办法
7448
查看次数

更改"警报"对话框中特定文本的颜色

嗨伙计们我有一个xml,我有以下内容:

John:How are you?
Mary:I am fine.How about you.
John:what is your plan today?
Run Code Online (Sandbox Code Playgroud)

我从xml中获取这些值.现在我需要John,Mary带有BOLD和的文本different color.而且我还需要更改警报窗口的背景颜色.

这是我正在使用的警报对话框:

AlertDialog.Builder bu = new AlertDialog.Builder(this);
bu.setMessage(""+((Node) textFNListU.item(0)).getNodeValue().trim().replace("$","\n"));
bu.setCancelable(true);
bu.setPositiveButton("OK",new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
        // TODO Auto-generated method stub
                    dialog.cancel();
                        }
                        });
                bu.create().show();
Run Code Online (Sandbox Code Playgroud)

((Node) textFNListU.item(0)).getNodeValue().trim()) ----这是我从xml获得的价值

请帮忙.

xml alert android android-alertdialog

0
推荐指数
1
解决办法
5319
查看次数

如何在android中连接服务器时显示进度条?

这是我连接到服务器并在MyUtilitiesActivity中获取响应的方法.

 private static response = "";
public static String send(final Activity act, final String url, final String keys[], final String values[]) 
{ 
    try{
        HttpParams httpParameters = new BasicHttpParams();
        // Set the timeout in milliseconds until a connection is established.

        HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
        // Set the default socket timeout (SO_TIMEOUT) 
        // in milliseconds which is the timeout for waiting for data.

        HttpConnectionParams.setSoTimeout(httpParameters, 5000);  

        HttpClient httpclient = new DefaultHttpClient(httpParameters);
        if(keys == null && values == null)
        {

            HttpGet get = new HttpGet(url);   
            // …
Run Code Online (Sandbox Code Playgroud)

android progress-bar

0
推荐指数
1
解决办法
2309
查看次数

在Android中的视图上应用并清除ColorFilter

我有两个不同父母的按钮.

我正在尝试将按钮效果应用于按钮触摸.

这是我的代码:

public class ButtonHighlighterOnTouchListener implements OnTouchListener {

    final Button button;

    public ButtonHighlighterOnTouchListener(final Button imageButton) {
      super();
      this.button = imageButton;
    }

    public boolean onTouch(final View view, final MotionEvent event) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            button.getBackground().setColorFilter(Color.parseColor("#B7B2B0"), PorterDuff.Mode.MULTIPLY);
            button.invalidate();
            break;
        case MotionEvent.ACTION_CANCEL:
            button.getBackground().clearColorFilter();
            button.invalidate();
            break;
        case MotionEvent.ACTION_UP:
            button.getBackground().clearColorFilter();
            button.invalidate();
            break;
        }
        return false;
        }
}
Run Code Online (Sandbox Code Playgroud)

它将效果应用于按钮,但问题是因为我有2个按钮,即使我点击一个按钮,效果也会应用到另一个按钮.

请帮我解决这个问题.

android effects colorfilter android-button android-drawable

0
推荐指数
1
解决办法
2万
查看次数

在运行时获取图像的宽度和高度 - WP8

我正在使用Windows Phone 8应用程序.

我有一条通往图像的道路 - /Data/Images/image1.png.我能够在屏幕上显示此图像,但我想在渲染之前更改图像的宽度和高度.

这就是我在显示图像的方式 webbrowser control

webbrowser.Append("<img src=""+path+ width=\"250\" height=\"250\" style=\"vertical-align:middle\" alt=\"\"></img>"/>"
Run Code Online (Sandbox Code Playgroud)

在这里我设置宽度和高度,250x250但我想改变高度和宽度,因为一些图像不好看.

c# silverlight image windows-phone windows-phone-8

0
推荐指数
1
解决办法
805
查看次数