小编zai*_*iff的帖子

使用Html.fromHtml在TextView中设置文本

我必须分三个部分显示文本,所以我使用了Html.fromHtml,如下所示:

txtvw.setText(Html.fromHtml("<p align=right> <b> "
                    + "Hi!" + " </br> <font size=6>"
                    + " How are you "+"</font> </br>"
                    + "I am fine" + "  </b> </p>"));
Run Code Online (Sandbox Code Playgroud)

HTML是正确的,但在设备中它显示在一行.

我的textview xml声明是:

   <RelativeLayout
    android:id="@+id/Home"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:background="@drawable/transparentfooter"
    android:layout_above="@+id/bottombar" >


     <TextView 
    android:id="@+id/txt"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:textColor="@android:color/white"/>

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android textview android-layout

15
推荐指数
1
解决办法
3万
查看次数

从资产中读取HTML文件

我在资产中有一个html文件,aaa.html.我想读取html文件的内容并将其替换为另一个字符串.

这种方式是对的还是有其他选择.

我的代码:

File f = new File("file:///android_asset/aaa.html");
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
Run Code Online (Sandbox Code Playgroud)

但是找不到给定文件,在web视图中加载文件时加载文件.

android

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

如何在android中备份整个应用程序?

我想存储/保存整个应用程序,即创建备份,以便在需要时,能够恢复相同的先前应用程序状态.可以使用备份管理器或任何其他方式完成.

android

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

发布包含下划线(_)的网址

我发布了一个带有下划线(_)的参数的网址.

样品: http://sdsdsds_asasasahjhd.com/dsdsdsd/login.json?

我发布的方式如下:

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://sdsdsds_asasasahjhd.com/dsdsdsd/login.json?");
    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("key1", "value1"));
        nameValuePairs.add(new BasicNameValuePair("key2", "value2"));
        nameValuePairs
                .add(new BasicNameValuePair("key3", "value3"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

    } catch (Exception e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

当我正在检查时,httpclient.execute(httppost)我正在IllegalArgumentException接收异常详细信息Host name cannot be null.请指明任何解决方案.

我在这里经历了一些其他问题:

但没有用,因为我没有编码整个网址.

android

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

从SD卡读取pdf文件

我想阅读存储在我的SD卡中的pdf文件,我尝试使用这个片段

    File file = new File(Environment.getExternalStorageDirectory()
            + "/vvveksperten" + "/ypc.pdf");

    PackageManager packageManager = getPackageManager();
    Intent testIntent = new Intent(Intent.ACTION_VIEW);
    testIntent.setType("application/pdf");
    List list = packageManager.queryIntentActivities(testIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(file);
    intent.setDataAndType(uri, "application/pdf");
    startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

但它给了我一个错误.

ERROR/AndroidRuntime(2611): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/vvveksperten/ypc.pdf typ=application/pdf }
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
2
解决办法
7675
查看次数

在图像视图中设置的位图未获得填充父级

我用这个压缩了图像:

      private Bitmap decodeFile(InputStream is){
        //decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(is,null,o);

        //Find the correct scale value. It should be the power of 2.
        final int REQUIRED_SIZE=100;
        int width_tmp=o.outWidth, height_tmp=o.outHeight;
        int scale=1;
        while(true){
            if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
                break;
            width_tmp/=2;
            height_tmp/=2;
            scale*=2;
        }

        //decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize=scale;
        return BitmapFactory.decodeStream(is, null, o2);
    }
Run Code Online (Sandbox Code Playgroud)

我在图像视图中设置此位图,但它在顶部和底部留下了一些空间.

我试过这个:

    img.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT));
    img.setImageBitmap(bm);
Run Code Online (Sandbox Code Playgroud)

但没用

还有其他方法吗?

android

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

在android中访问设备的"设置"

我想知道设备中存在的"设置"的路径.由于存在到达收件箱的路径,因此设置有什么内容.

android

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

标签 统计

android ×7

android-layout ×1

textview ×1