小编Mar*_*eiz的帖子

Android:如何检查文件是否是图像?

可能重复:
知道文件是否是Java/Android中的图像

如果文件是图像,我该如何检查?如下:

如果(file.isImage)....

如果标准库无法实现,我怎样才能使用MagickImage lib?

提前致谢!

android listview image imagemagick

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

Android:如何通过FTPClient获取FTP文件的文件大小?

如何读取存储在ftp服务器上的文件的文件大小?我不喜欢实现另一个库.

我正在使用commons-io-2.4和commons-net-3.1

来自talhakosen的答案和代码(谢谢!)

private long getFileSize(FTPClient ftp, String filePath) throws Exception {
    long fileSize = 0;
    FTPFile[] files = ftp.listFiles(filePath);
    if (files.length == 1 && files[0].isFile()) {
        fileSize = files[0].getSize();
    }
    Log.i(TAG, "File size = " + fileSize);
    return fileSize;
}
Run Code Online (Sandbox Code Playgroud)

ftp android filesize download

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

Android:如何使用simpleadapter将sd卡中的图像文件放到HashMap中?

我正在读取手机上所选文件夹中的文件,就像您在下面的代码中看到的那样.我怎么能用Imagefile来完成这项工作?最后,我喜欢有一个图像列表,其中包含每个图像的预览.像那样:

[IMG](imgview) - [文件名](字符串)

        for(int i=0; i < files.length; i++) {

        File file = files[i];
            map = new HashMap<String, String>();
        if(!file.isHidden() && file.canRead()) {
            path.add(file.getPath());

            if(file.isDirectory()) {
                map.put("img_list", ""+R.drawable.folder);
                map.put("string_cell", file.getName()+"/");
                your_array_list.add(map);

            }else{


                ImageFileFilter filefilter = new ImageFileFilter(file);

                if(filefilter.accept(file)){
                   //Its an imagefile

                    // ==> I like to replace the ""+R.drawable.image with the file that I have read
                    map.put("img_list", ""+R.drawable.image);


                } else {

                    //Its not an image file

                }

                map.put("string_cell", file.getName());
                your_array_list.add(map);

            }
        } 


    }

        SimpleAdapter mSchedule = new SimpleAdapter(this, your_array_list, …
Run Code Online (Sandbox Code Playgroud)

android listview image hashmap simplecursoradapter

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

Android:如何为不同的Android版本使用不同的主题?

MinSDKVersion = 7 TargetSDKVersion = 17

如果用户拥有SDKVersion 11或更高版本,我想将主题设置为Theme.Holo.Light.它在这里对我不起作用.当我在3.1设备上启动应用程序时,它只使用Theme.Light:

在此输入图像描述

当我在版本低于3.1的设备上运行此应用程序时也是如此

我的文件夹结构:

在此输入图像描述

表现:

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyTheme" >
Run Code Online (Sandbox Code Playgroud)

值-V11:

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Light">
    <!-- All customizations that are NOT specific to a …
Run Code Online (Sandbox Code Playgroud)

android themes manifest

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

游标崩溃:请求索引0,大小为0

我不知道为什么我的光标是空的.我读了其他4-5个问题,其中包含相同的信息,但我无法解决我的问题.我忘记了什么?

使用此代码,我收到消息:"光标为空":

    public void onClick(View arg0) {
        String txt_edit_hw = edit_hw.getText().toString(); 
        ContentValues args = new ContentValues();
        args.put("hw", txt_edit_hw);

        String test = "SELECT _id FROM tbl_homework where hw='"+ txt_edit_hw +"';";

        Cursor mCursor = db.rawQuery(test, null); 

        startManagingCursor(mCursor);
        if (mCursor.moveToFirst()){

        String hw = mCursor.getString(mCursor.getColumnIndex("hw"));


        doMessage(hw);
        db.update("tbl_homework", args, "_id=34", null);
        fillData();
        } else {
            doMessage("Cursor is empty");
        }
    }
Run Code Online (Sandbox Code Playgroud)

有了这段代码我得到了...请求android索引0,大小为0:

    public void onClick(View arg0) {
        String txt_edit_hw = edit_hw.getText().toString(); 
        ContentValues args = new ContentValues();
        args.put("hw", txt_edit_hw);

        String test = "SELECT _id FROM tbl_homework where …
Run Code Online (Sandbox Code Playgroud)

sqlite android cursor

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

为什么我的Dialog Seekbar会崩溃?空指针异常

我在对话框上有一个搜索栏,它正在崩溃.它说有一个nullpointerexeption.但我找不到它!我的错误在哪里?我评论了nullpointer exeption的位置.

dialog_context_mark.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/add_hw_dialog"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="10dp" >

    <RelativeLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    <TextView
        android:id="@+id/txt_gewicht"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Gewicht: " />

    <TextView
        android:id="@+id/txt_weight_change"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"/>

    </RelativeLayout>
    <SeekBar
        android:id="@+id/seekBar_wertung"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

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

mark.java

在公共类标记我定义它是这样的:

SeekBar seek_gewicht;
SeekBar seekBar_wertung;
TextView gewicht;
Run Code Online (Sandbox Code Playgroud)

OnSeekBarChangeListener:

    OnSeekBarChangeListener yourSeekBarListener = new OnSeekBarChangeListener() {

    public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
     // TODO Auto-generated method stub
     gewicht.setText(progress+"%");

    }

    public void onStartTrackingTouch(SeekBar seekBar) {
    }

    public void onStopTrackingTouch(SeekBar seekBar) {
     seekBar.setSecondaryProgress(seekBar.getProgress());
    }

    };
Run Code Online (Sandbox Code Playgroud)

我的对话: …

android nullpointerexception seekbar

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

Android:如何在SD卡上搜索文件?

如果输入的字符串,如何在我的SD卡上搜索文件?

我想搜索"test",并希望获得一个列表,其中包含名称中包含字符串"test"的所有文件:

testfile.txt

filetest.jpg

thisisatestfile.xml
Run Code Online (Sandbox Code Playgroud)

等等

search android list sd-card

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

如何解释以下术语(Cursor,Context,DatabaseHelper)

如果有人问你:这些术语代表什么?

您如何向没有发展经验的人解释?

android

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

如何从图像路径显示缩略图?

如何在ImageView中显示固定图像路径的缩略图?

android thumbnails show imageview

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