移动端开发新手求教:代码中-->的名称与IDE自动补全异常问题
Hey there! Let's work through your questions step by step—since you're new to mobile development, these syntax and IDE quirks can definitely feel confusing at first.
1. What is the --> in (e) -->? Is it a pointer?
Nope, that's not a pointer at all! The actual syntax you should be using here is ->—the --> you're seeing is just an HTML-escaped version of the lambda arrow (the original code in the video uses -->, which translates to -> in plain Java).
This -> is part of Java 8+ Lambda Expressions, which let you write concise callback code instead of verbose anonymous inner classes. For example, your code should look like this:
uploadTask.addOnFailureListener((e) -> { finish(); }); mProfileImage.setOnClickListener((view) -> { saveUserInformation(); });
Lambdas are used heavily in Android for listeners and async callbacks to keep code clean.
2. Why is (e) --> grayed out and missing from auto-complete?
The grayed-out text and lack of auto-complete are because --> is not valid Java syntax! You probably either copied the escaped HTML text directly from the video's code block or mistyped the lambda arrow.
Additionally, make sure your Android project is configured to support Java 8 or higher:
- Open your app-level
build.gradlefile - Check that these lines are present (and set to 1.8 or higher):
android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
If your project doesn't support Java 8, the IDE won't recognize lambda expressions at all, so auto-complete won't show them.
3. Why does quality 20 appear grayed out in bitmap.compress()?
That's totally normal! The grayed-out quality is an IDE parameter name hint (from Android Studio/IntelliJ IDEA). It's just there to remind you that the second argument to compress() is the quality percentage for the JPEG.
This hint doesn't affect your code—you can just type 20 and the hint will disappear once you move on. If you find it distracting, you can turn it off by going to File > Settings > Editor > Inlay Hints > Java > Parameter names and unchecking the relevant options.
内容的提问来源于stack exchange,提问作者Joe

