2017-04-08 2 views
0

Wir verwenden Bitmap-Klasse für imageview_und ich möchte wissen, was die Klasse für videoview statt Bitmap?Bitmap-Klasse für Videobild

+0

Versuchen Sie, Ihre Frage besser zu machen, zeigen Sie, was Sie in Code versucht haben .. wenn nicht ich denke, diese Frage wäre geschlossen – nachokk

+0

Ich möchte auf Aktivität statt viele Aktivitäten für meine Listview'item –

+0

erstellt werden In der anderen Hand verwenden wir eine Bitmap-Klasse für imageview_what die Klasse für die Videoansicht anstelle von Bitmap –

Antwort

1

** Beispiel für 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

Verwandte Themen