如何在目录中添加默认图像???在创建新目录时

时间:2013-05-02 14:22:31

标签: java android

创建目录时如何添加默认图像?这是我的代码,下面使用alert dailog创建目录,但是如果创建目录,我想自动添加默认图像,我该怎么办?

Deault图片ID为(R.drawable.myimage)。我想在创建目录时在目录中添加此图像。

AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Add New Photo Folder"); // Set Alert dialog

// title here
alert.setMessage("Enter Folder Name "); // Message here

// Set an EditText view to get user input
final EditText input = new EditText(context);
alert.setView(input);

alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
        String srt = input.getEditableText().toString();
        Toast.makeText(context, srt, Toast.LENGTH_LONG).show();

        File photos = new
        File(getFilesDir(), srt);

        if (!photos.exists()) {
            photos.mkdirs();

            gridView.invalidateViews();
            gridView.setAdapter(simpleAdapter);

            inflateListView(currentFiles);
            finish();

            startActivity(getIntent());
        } else {
            Toast.makeText(context, "Already Exist This folder", Toast.LENGTH_LONG).show();
        }
    }
});

alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
        // Canceled.
        dialog.cancel();
    }
}); // End of alert.setNegativeButton

AlertDialog alertDialog = alert.create();

0 个答案:

没有答案