Source of type conversion errors that are thought of by "type Mismatch:cannot convert from View to ProgressBar"

Source: Internet
Author: User

In my self-study of Android, I was never able to get ProgressBar by ProgressBar ID when I was training to use ProgressBar. Always quote "Type Mismatch:cannot convert from View to ProgressBar" error. Check code, no errors found. Two nights, none of them were checked out.

After searching the internet, I found it very rare to ask this question. And there is no detailed discussion of the source of the problem.


I'll discuss the issue in detail here.

I have never encountered such a problem when I was learning Corejava. It's in Android. The class name I built is ProgressBar, and then I want to get control ProgressBar. Everyone should see the mistake. ProgressBar is an existing class on Android, and the activity I build is also class. The class name is conflicting. The IDE tool does not automatically recognize whether to get my own activity or to get a control. So the error.

In Corejava, no one will build a "String" class, because this class is already in Java. But in Android, we thought we were building an activity, but the activity is still class, it's a special class that inherits the activity, and it still has to

Comply with rules that cannot be duplicated by class names.

This is the root of the error. The understanding of the activity is not thorough, resulting in an error.

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.