Rating page
Xmlns: tools = "http://schemas.android.com/tools"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
>
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: rating = "3"
Android: numStars = "5"
Android: stepSize = "0.5"
Android: id = "@ + id/star"/>
Click Event
RatingBar = (RatingBar) findViewById (R. id. star );
RatingBar. setOnRatingBarChangeListener (new OnRatingBarChangeListener (){
@ Override
Public void onRatingChanged (RatingBar ratingBar, float rating,
Boolean fromUser ){
Toast. makeText (MainActivity. this, "score:" + rating, Toast. LENGTH_LONG). show ();
}
});
For TextSwitcher text switching, import android. widget. FrameLayout. LayoutParams. Generally, the android. widget. AbsListView. LayoutParams parameter is used to set the listview width and height.
Android: id = "@ + id/switcher"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
Image Switching
Android: id = "@ + id/switcher"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
Almost all implementation classes
// Switcher = (TextSwitcher) findViewById (R. id. switcher );
Switcher = (ImageSwitcher) findViewById (R. id. switcher );
// Set up the factory class and return the internal components displayed
Switcher. setFactory (new ViewFactory (){
@ Override
Public View makeView (){
// Create a textview for the text to be displayed
/* TextView text = new TextView (MainActivity. this );
Text. setTextColor (Color. BLACK );
Text. setTextSize (16 );
Text. setBackgroundColor (Color. WHITE );
Text. setLayoutParams (new LayoutParams (
LayoutParams. MATCH_PARENT, LayoutParams. MATCH_PARENT ));
Return text ;*/
ImageView img = new ImageView (MainActivity. this );
Img. setLayoutParams (new LayoutParams (LayoutParams. MATCH_PARENT, LayoutParams. MATCH_PARENT ));
Return img;
}
});
// Process content
// Switcher. setText (allTexts [index]);
Switcher. setImageResource (allImgs [index]);
// Set the animation effect. The system animation function is incomplete and generally cannot meet the development requirements. Therefore, a custom Pan animation is completed here.
// Switcher. setInAnimation (AnimationUtils. loadAnimation (this,
// Android. R. anim. slide_in_left ));
// Switcher. setOutAnimation (AnimationUtils. loadAnimation (this,
// Android. R. anim. slide_out_right ));
// Adds a touch screen listener. The prerequisite for using this listener is that the component must have been added to the OnClickListener first.
Switcher. setOnClickListener (new OnClickListener (){
@ Override
Public void onClick (View v ){
}
});
Switcher. setOnTouchListener (new OnTouchListener (){
@ Override
Public boolean onTouch (View v, MotionEvent event ){
// Supports multi-point operations, but this program only sets single-point operations
If (event. getPointerCount () = 1 ){
If (event. getAction () = MotionEvent. ACTION_DOWN ){
// Just reached the screen
StartX = event. getX ();
StartTime = System. currentTimeMillis ();
} Else if (event. getAction () = MotionEvent. ACTION_MOVE ){
// Moving
} Else if (event. getAction () = MotionEvent. ACTION_UP ){
// Lift your finger
// Judge the current abscissa difference, complete the motion in one second, and the sliding line spacing is greater than 50
If (System. currentTimeMillis ()-startTime <1000 ){
If (startX-event. getX ()> = 50 ){
// Slide left, that is, the next page
If (index <allImgs. length-1 ){
Index ++;
// The animation to be entered is the sliding public TranslateAnimation.
// (Float fromXDelta, float toXDelta, float
// FromYDelta, float toYDelta)
Animation inAnim = new TranslateAnimation (
Globals. SCREEN_WIDTH + 10, 0, 0, 0 );
Animation outAnim = new TranslateAnimation (
0,-Globals. SCREEN_WIDTH-10, 0, 0 );
// Set the animation duration
InAnim. setDuration (1000 );
OutAnim. setDuration (1000 );
Switcher. setInAnimation (inAnim );
Switcher. setOutAnimation (outAnim );
Switcher. setImageResource (allImgs [index]);
}
} Else if (event. getX ()-startX> = 50 ){
// Previous Page
If (index> 0 ){
Index --;
Animation inAnim = new TranslateAnimation (
-Globals. SCREEN_WIDTH-10, 0, 0, 0 );
Animation outAnim = new TranslateAnimation (
0, Globals. SCREEN_WIDTH + 10, 0, 0 );
// Set the animation duration
InAnim. setDuration (1000 );
OutAnim. setDuration (1000 );
Switcher. setInAnimation (inAnim );
Switcher. setOutAnimation (outAnim );
Switcher. setImageResource (allImgs [index]);
}
}
}
}
} Else {
Toast. makeText (MainActivity. this, "supports single-point operations ",
Toast. LENGTH_SHORT). show ();
}
Return false;
}
});
Contentresolver scans sdcard to find video resources
// Call certain database operations based on a unique identifier.
Cursor c1 = resolver. query (MediaStore. Video. Media. EXTERNAL_CONTENT_URI,
Null, null );
If (c1.moveToFirst ()){
While (! C1.isAfterLast ()){
String album = c1.getString (c1.getColumnIndex (Video. Media. ALBUM ));
String artist = c1.getString (c1.getColumnIndex (Video. Media. ARTIST ));
String fileName = c1.getString (c1.getColumnIndex (Video. Media. DISPLAY_NAME ));
String name = c1.getString (c1.getColumnIndex (Video. Media. TITLE ));
String duration = c. getString (c1.getColumnIndex (Video. Media. DURATION ));
String path = c1.getString (c1.getColumnIndex (Video. Media. DATA); // path
MediaPlayer player = new MediaPlayer ();
System. out. println (album + "-->" + artist + "-->" + name
+ "-->" + Duration + "-->" + path + "-->"
+ FileName );
C1.moveToNext ();
}
}
C1.close ();