2017-04-08 58 views
0

我们对imageview_and使用位图类,我想知道什么类的视频,而不是位图?videoview的位图类

+0

试着让你的问题变得更好,展示你在代码中所做的事情..如果不是,我认为这个问题将被关闭 – nachokk

+0

我想在活动中创建而不是为我的Listview'item –

+0

创建另一方面我们使用一个位图类,用于imageview_what视频视图的类而不是位图 –

回答

1

** VideoView的实施例**

MainActivity.java

private VideoView videoView; 
     private Button videoPlay; 

      @Override 
      public void onCreate(Bundle savedInstanceState) { 
       super.onCreate(savedInstanceState); 
       setContentView(R.layout.main); 
       videoView = (VideoView)findViewById(R.id.VideoView);   

    videoPlay=(Button)findViewById(R.id.button); 
    videoPlay.setOnClickListener(this); 

      } 
@Override 
    public void onClick(View v) { 
if(v==videoPlay){ 
videoView.setVideoPath("/sdcard/blonde_secretary.3gp"); 
       videoView.start(); 
} 
} 

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.videotest.MainActivity"> 

    <VideoView 
     android:id="@+id/videoview" 
     android:layout_width="300dp" 
     android:layout_height="200dp"/> 

    <Button 
     android:text="Play" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/videoview" 
     android:onClick="onButtonClick" 
     android:id="@+id/button"/> 

</RelativeLayout> 

enter image description here