如何在我的Android应用程序中创建上述视图?

时间:2011-04-28 03:57:46

标签: java android xml

因为我正在创建一个类似于下面显示的应用程序,但我不知道如何创建一个类似于上面显示的视图,我点击一个按钮导航到这个页面,其中所有的视频和地图日志文件显示.. 我是android / java中的新手可以有人指导我这个吗?

编辑:这是一系列用于创建存储我的视频文件的目录的代码,但是这些文件只能在应用程序之外看到,但我想在应用程序中看到它,当按下按钮时它会导航到VideoList浏览我拍摄的各种视频文件,按下它时会显示here的自定义屏幕。但要实现这一目标应该做些什么呢?

File dirlist = new File(Environment.getExternalStorageDirectory() + "/VideoList");
if(!(dirlist.exists()))    
dirlist.mkdir();
File TempFile = new File(Environment.getExternalStorageDirectory()                     + "/VideoList", dateFormat.format(date) + fileFormat);
mediaRecorder.setOutputFile(TempFile.getPath());

2 个答案:

答案 0 :(得分:0)

zack它是自定义对话框你需要创建自定义对话框

了解更多信息..转到此link 1) link 2

答案 1 :(得分:0)

Hay Zack它的自定义Dialog检查了这个...代码

main.xml (您的主页面布局)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is my main activity, from here, I want to display a dialog, after the user clicked the button below this text.">
</TextView>
<Button android:layout_height="wrap_content"
android:layout_below="@+id/TextView01"
android:layout_width="wrap_content"
android:id="@+id/Button01main"
android:text="Hey! There is more..."></Button>
</RelativeLayout>

maindialog.xml (您的对话框布局页面)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:id="@+id/ImageView01"
 android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="wrap_content" android:layout_below="@+id/ImageView01"
android:layout_height="200px">
 <TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</ScrollView>
<Button android:id="@+id/Button01" android:layout_below="@id/ScrollView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:text="Cancel" />
</RelativeLayout>

dilo.java (点击按钮代码显示对话框)

package com.example.dilo;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class dilo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button1main = (Button) findViewById(R.id.Button01main);

        button1main.setOnClickListener(new OnClickListener() {

        @Override

            public void onClick(View v) {

                //set up dialog
                final Dialog dialog = new Dialog(dilo.this);
                dialog.setContentView(R.layout.maindialog);
                dialog.setTitle("This is my custom dialog box");
                dialog.setCancelable(true);
                //there are a lot of settings, for dialog, check them all out!
                //set up text
                TextView text = (TextView) dialog.findViewById(R.id.TextView01);
                text.setText(R.string.lots_of_text);
                //set up image view
                ImageView img = (ImageView) dialog.findViewById(R.id.ImageView01);
                img.setImageResource(R.drawable.icon);
                //set up button
                Button button = (Button) dialog.findViewById(R.id.Button01);
                button.setOnClickListener(new OnClickListener() {
                @Override
                    public void onClick(View v) {
                        dialog.cancel();
                    }
                });
                //now that the dialog is set up, it's time to show it   
                dialog.show();
            }
        });

   }
}

我认为它应该对你有帮助......好吧...... N欢乐