Home > Mobile >  When android page jump to collapse
When android page jump to collapse

Time:10-18

Just began to learn the Android, do a first APP, the normal operation, then hard moved from elsewhere a round figure, listview list page collapses
 import Java IO. The File; 
import java.util.ArrayList;
Import the Java. Util. HashMap;
import java.util.List;
Import the Java. Util. The Map;
Import the Java. Util. The Timer;
Import the Java. Util. TimerTask;

The import android. App. The Activity;
The import android. App. AlertDialog;
Import android. Content. DialogInterface.
The import android. Content. Intent;
The import android. Database. Cursor;
The import android. Database. Sqlite. SQLiteDatabase;
The import android. Graphics. Bitmap;
The import android. Graphics. BitmapFactory;
The import android. OS. Bundle;
The import android. OS. Handler;
The import android. Support. The v4. View. ViewPager;
The import android. View. KeyEvent;
The import android. View. The view;
The import android. View. The view. An OnClickListener;
Window; import android. The view.
The import android. Widget. Adapter;
The import android. Widget. AdapterView;
The import android. Widget. The Button;
The import android. Widget. ImageView;
The import android. Widget. ListView.
The import android. Widget. SimpleAdapter;
The import android. Widget. TextView;
The import android. Widget. AdapterView. OnItemClickListener;

Public class LookActivity extends the Activity {
Private Button myHomeBtn myselfBtn;
Private ListView result;
Private TextView userName, mood;
Private String userId, name, headName;
Private ImageView head;
MyDatabaseHelper mydbHelper;
Private ViewPager mMyViewPaper;
Private List Images;
Private List Dots;
Private int currentItem;
Private MyAdapter adapter.
//the currently displayed image position
Private int localPosition=0;
//picture id
Private int [] imageIds=
New int [] {R.d rawable dot_0, R.d. Rawable dot_1, R.d. Rawable dot_2, R.d. Rawable dot_3, R.d rawable. Dot_4};
The title of the//picture
Private TimerTask mTimerTask;
//create a timer
Private final Timer Timer=new Timer ();
Private ImageView mImageView;

Protected void onCreate (Bundle savedInstanceState) {
Enclosing requestWindowFeature (Window. FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
CloseActivityClass. ActivityList. Add (this);
The setContentView (R.l ayout. Activity_look);

MyHomeBtn=(Button) the findViewById (R.i d.h. omeBtn);
MyselfBtn=(Button) the findViewById (R.i d.m yselfBtn);
Result=(ListView) the findViewById (R.i d.r esult);

//pass information
Intent Intent=getIntent ();
UserId=intent. GetStringExtra (" userId ");

MyHomeBtn. SetOnClickListener (new an OnClickListener () {
Public void onClick (View v) {
Intent Intent=new Intent (LookActivity. This,
HomeActivity. Class);
Intent. AddFlags (intent. FLAG_ACTIVITY_REORDER_TO_FRONT);
Intent. PutExtra (" userId ", userId);
Intent. PutExtra (" sign ", "0");
Intent. PutExtra (" isBackLook ", "yes");
StartActivity (intent);
System. The exit (0);
}
});

MyselfBtn. SetOnClickListener (new an OnClickListener () {
Public void onClick (View v) {
Intent Intent=new Intent (LookActivity. This,
MyselfActivity. Class);
Intent. AddFlags (intent. FLAG_ACTIVITY_REORDER_TO_FRONT);
Intent. PutExtra (" userId ", userId);
Intent. PutExtra (" sign ", "0");
Intent. PutExtra (" isBackLook ", "yes");
StartActivity (intent);
System. The exit (0);
}
});
MMyViewPaper=(ViewPager) the findViewById (R.i d.v p);

//image
Images=new ArrayList<> (a);
For (int I=0; I & lt; ImageIds. Length; I++) {
MImageView=new ImageView (this);
MImageView. SetBackgroundResource (imageIds [I]);
Images. The add (mImageView);
}

Dots=new ArrayList<> (a);
Dots. The add (the findViewById (R.i d.d ot_0));
Dots. The add (the findViewById (R.i d.d ot_1));
Dots. The add (the findViewById (R.i d.d ot_2));
Dots. The add (the findViewById (R.i d.d ot_3));
Dots. The add (the findViewById (R.i d.d ot_4));

Adapter=new MyAdapter (LookActivity. This, images);
MMyViewPaper. SetAdapter (adapter);
MMyViewPaper. SetOnPageChangeListener (new ViewPager. OnPageChangeListener () {

@ Override
Public void onPageSelected (int position) {
Position the position of=% images. The size ();
Dots. Get (position). SetBackgroundResource (R.d rawable. Dot_0);
Dots. Get (localPosition). SetBackgroundResource (R.d rawable. Dot_1);

LocalPosition=position;
CurrentItem=position;
}
/* *
* page sliding callback
*/
@ Override
Public void onPageScrolled (int arg0, float arg1, int arg2) {

}
/* *
* when the ViewPager state changes, the callback
*/
@ Override
Public void onPageScrollStateChanged (int state) {
}
});

MydbHelper=new MyDatabaseHelper (LookActivity. This "topic. Db", null,
1);//create the database auxiliary class
SQLiteDatabase db=mydbHelper. GetReadableDatabase ();//get the SQLite database

//configuration adapter shows the topic list
SimpleAdapter adapter=new ImageSimpleAdapter (this, getData (db),
R.l ayout listview_look, new String [] {" date ", "body",
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related