我开发了简单的图像应用程序,假设从左向右滑动图像。阅读此链接后http://developer.android.com/training/sharing/shareaction.html#set-share-intent。我在mainActivity.java中实现了代码。此代码假设在操作栏的顶部显示共享选项。但是,我在这个代码附近得到了一个小黄灯..private void setShareIntent(Intent shareIntent){...这是什么意思..以下是我的mainActivity.java代码..
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ShareActionProvider;
public class MainActivity extends Activity {
MediaPlayer oursong;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
oursong = MediaPlayer.create(MainActivity.this, R.raw.a);
oursong.start ();
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
ImageAdapter adapter = new ImageAdapter(this);
viewPager.setAdapter(adapter);
}
private ShareActionProvider mShareActionProvider;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.activity_main, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
// Return true to display menu
return true;
}
@Override
protected void onPause(){
super.onPause();
oursong.release();
}
}
错误问题
Description Resource Path Location Type
[Accessibility] Missing contentDescription attribute on image fullimage.xml /Grid View/res/layout line 6 Android Lint Problem
Description Resource Path Location Type
<uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion="?" AndroidManifest.xml /Copy of galleryDemo line 7 Android Lint Problem
Description Resource Path Location Type
Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details. AndroidManifest.xml /DailySounds line 8 Android Lint Problem
Description Resource Path Location Type
Should explicitly set android:allowBackup to true or false (it's true by default, and that can have some security implications for the application's data) AndroidManifest.xml /Copy of galleryDemo line 10 Android Lint Problem
Description Resource Path Location Type
The value of the field MainActivity.mShareActionProvider is not used MainActivity.java /Copy of ViewpagerImageGallery/src/com/manishkpr/viewpagerimagegallery line 29 Java Problem
Description Resource Path Location Type
This method has a constructor name MainActivity.java /SecondActivityApp/src/com/secondactivityapp line 28 Java Problem
Description Resource Path Location Type
Use a layout_height of 0dp instead of wrap_content for better performance fullimage.xml /Grid View/res/layout line 9 Android Lint Problem
的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.manishkpr.viewpagerimagegallery"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.manishkpr.viewpagerimagegallery.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
如果该行旁边只有一个“黄灯”图标,那么它只是一个警告。无论如何,你的程序都会顺利运行,但它只是声明你的程序中的任何地方都没有使用它(它被放置在那里不必要)所以你应该尝试删除那一行。如果您的程序仍然顺利运行,那么您就完成了。