Errors in Listview Customization

Asked

Viewed 64 times

3

Well, I’ve been trying to personalize a Listview in my project, and I finished it and it was all right. However, an API error appeared stating that the minimum API I used was very low. I used the eclipse correction option without knowing if employee, the error was gone and then tried to run the APK. Unfortunately it did not open and the system reported that the application stopped.

I figured the one responsible for this was that API error. I tried to create another project with a smaller API, but when copying the code several errors appeared. The Gets I used in one of the classes stopped working for no apparent reason. I have an error in Actionbaractivity in another class. When importing, it gets the yellow risk below and stops working, as well as the import of it. If I remove the import, it turns red. Also and I’m not sure what the reason is. Follow the screenshots of the classes with errors.

Erros de get Erros na ActionBarActivity

  • You are at risk because you are depreciated, see direct from documentation.

  • ArrayList is in yellow because it is not in use, the import was done, but the class was not used in the code.

  • As to the itemPosicao, this class Item it was you who created it? If yes, add it to the question as well. Also add what message the IDE shows in the variable with red risk.

  • Well Diego, I understand that the yellow risk implies that I am not using, but why that risk in the middle of "Actionbaractivity"? This is the Gets error. http://prntscr.com/95dyqa And yes, I created the Item class. Follow the code. http://prntscr.com/95e07u

  • See my first comment, in it is the answer of why the class "Actionbaractivity" is at risk. I suggest you to post the item class code here too, and the error that is appearing in the red subliming.

  • I posted above the screenshots hosted by lightshot. Unfortunately the comment removes the formatting of the code and gets confused. In any case, the get error message is: The method getx() is Undefined for the type Clipdata.Item

  • You can paste the code into the question, then select all the code and click on the option {} that it appears formatted.

Show 2 more comments

1 answer

1

The risk is a warning that the class you are using is obsolete, this can be confirmed in the class documentation itself Actionbaractivity. You can use the class Appcompatactivity as a substitute, as long as you do not make use of any critical feature of the obsolete class, then the recommended is you revise your code in order to adapt the functionalities to the new class.

Regarding the error the methods of the variable itemPosicao, may be because you must be using android class too Clipdata.item. Check if you correctly imported your custom class item instead of the android class, and if the variable itemPosicao is the type of your class item or the type of native android class.

As a suggestion, you could change the name of your custom class, preventing it from conflicting with native classes, using names that better define what type of item it is. An example on own android, is the menu possesses menuItem.

References:

Android Documentation

  • Well, how to solve the problem of class being depreciated (if that is a problem)? About Clipdata.Item, I realized I had an import of it, deleted it and the errors were gone, but a number of errors appeared in the Listaitemactivity class. The constructor Clipdata.Item(int, int, String, String) is Undefined. The constructor Listaadapteritem(Listaitemactivity, Arraylist<Clipdata.Item>) is Undefined

  • @Rodrigop. updated the answer. Do not remove the import. Do what I quoted in the answer regarding the variable itemPosicao.

  • Thank you very much, Diego. I managed to solve all the mistakes just by making this little change, I would never have imagined it alone. However, a last error appeared, again an API error. Call requires API level 11 (Current min is 8): android.app.Activity#onCreateView. What is the most viable solution for this small error?

  • @Rodrigop. This new class requires api 7 as a minimum, not 11 as I stated.

  • There’s no way, I’ll have to create another one then, right? I understand, thank you for all your help, my dear.

  • @Rodrigop. I was wrong, the minimum api is 7. You are probably using another resource that requires 11 as a minimum, it is not due to the appcompat class.

  • This is very strange. I created the project with the minimum API at 16. I’m not sure what the reason for this API error is.

  • @Rodrigop. I suggest you create another question regarding your project’s api and what the ide is demanding by also adding your app’s setup xml file, so it’s easier for the guys here to help you. and do not forget to close this question as resolved.

  • 1

    Okay. Again, thank you very much.

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.