Android Development Missing ContentDescription attribute on image in XML

Source: Internet
Author: User

Recently in doing Android development, just getting started, encountered a lot of problems, accumulated the habit of doing refactoring, encountered problems, a good solution, a good summary, and then sorted as follows:

One. Eclipse Error
1. ' Missing contentdescription attribute on image ' in XML
reason: Missing a picture description, this warning will be thrown at the beginning of ADT 16 to ensure that the developer adds a description of the content to the picture.

Workaround: Add the android:contentdescription= "@string/desc" property to the picture.

2. Buttons in button bars should is borderless
reason: Two Buttons placed in a layout will be judged as a button bar, you need to add a style to remove its borders.

Workaround: Add attributes on Buttons style= "? Android:attr/buttonbarbuttonstyle". Are you prompted to add style= to the button's parent layout? Android:attr/buttonbarstyle "property, but I tested on the linear layout is not valid, ask the expert guidance!

Two. Development skills
1. Adjustments to trigger the previous activity in a newly opened activity
For example: the original page corresponding class is main.class (main code)

The code is as follows Copy Code

public class Main extends activity {

Button page;

@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);

page = (Button) Findviewbyid (R.id.open);

Page.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View source) {
Intent Intent = new Intent (main.this, Newpage.class);

Starts the intent corresponding activity and waits for it to return the result, where 0 is the identity code
Startactivityforresult (Intent, 0);
}
});

@Override
public void Onactivityresult (int requestcode, int resultcode, Intent Intent) {

if (Requestcode = = 0 && resultcode = 0) {//Confirm request ID and feedback result identification code is 0
Change this page or other action
}
}

}

public class NewPage extends activity {

Button Cancel;

Intent Intent;

@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.newpage);

Gets the Intent from the previous page.
Intent = this.getintent ();

Cancel = (Button) Findviewbyid (r.id.confirm);
Cancel.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View source) {
Feedback results, intent back to the previous activity, triggering the Onactivityresult method on the previous page, overriding the method to make adjustments to the original page
NewPage.this.setResult (0, intent);
NewPage.this.finish ();
}
});

}

}

If you need to transfer data between activity, you can also use Bunble to save and retrieve data in intent.

2. Get the location of the clicked item in the list
Extend the Baseadapter class, rewrite the GetView method, the first method is the location of the item, to match cursor use, you can use Cursor.movetoposition (position) to cursor Move to the corresponding data row in the database for the item.

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.