Android Development Notes (ii)

Source: Internet
Author: User

Motivation:

Development of a back word software. The feature of the screen is not implemented.

Method:

The first step is to try:

In Mainactivity, when you add the following code, the time in the text box changes when you click in the blank space of the view.

@Override
public boolean ontouchevent (Motionevent event) {
TODO auto-generated Method Stub
Final TextView TextView = (TextView) Findviewbyid (R.ID.TEXT2);
Date date = new Date ();
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");
String currentdate = Sdf.format (date);
Textview.settext (currentdate);
Return Super.ontouchevent (event);
}

The second step is to try:

@Override
public boolean ontouchevent (Motionevent event) {
if (event.getaction () = = Motionevent.action_down) {
int screenwidth = Getwindowmanager (). Getdefaultdisplay (). GetWidth ();
int screenheight = Getwindowmanager (). Getdefaultdisplay ()
. GetHeight ();
if (Event.getx () < SCREENWIDTH/2) {
if (StartPage > 1)
startpage--;
Else
Toast.maketext (Readview.this, "Already the first page", Toast.length_long)
. Show ();
} else {
if (StartPage < totalpages)
startpage++;
Else
Toast.maketext (Readview.this, "Already the last page", Toast.length_long)
. Show ();
}
Refreshlist ();
}
Return Super.ontouchevent (event);
}

This realizes the function of the touch screen paging.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.