SlidingMenu导入出错的终极解决方案
2013-06-22 21:24
471 查看
SlidingMenu开源项目下载地址:https://github.com/jfeinstein10/slidingmenu
Actionbarsherlock开源项目下载地址:http://actionbarsherlock.com/download.html
导入步骤如下:
1.将下载的Actionbarsherlock中/actionbarsherlock文件夹复制到workspace(你的项目工作空间),改名为Actionbarsherlock,从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为api14以上。
2.将下载的slidingmenu中/library文件夹复制到workspace(你的项目工作空间),改名SlidingMenu,从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为Google APIs 14以上。或者打开project.properties:target=Google Inc.:Google APIs:14或更高。
3.这样SlidingMenu就可以用在自己项目中了。让我们来运行例子。解压slidingmenu中/example。从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为api14以上。运行看看效果。2.1以上的系统都可以运行。
导入之后可能会出现的问题如下:
1、SlidingMenu library project出现错误
Console error: Unable to resolve target ‘Google Inc.:Google APIs:16.
Fix:进入Properties检查Target sdk是否选择了 Google APIs.
List of errors: ACTION_POINTER_INDEX_MASK cannot be resolved android.
HONEYCOMB cannot be resolved or is not a field
LAYER_TYPE_HARDWARE cannot be resolved or is not a field
LAYER_TYPE_NONE cannot be resolved or is not a field
MATCH_PARENT cannot be resolved or is not a field
The method getLayerType() is undefined for the type View
The method setLayerType(int, null) is undefined for the type View
Fix: 将manifest里面的min sdk version 改为你当前用到的sdk版本,7
2、SlidingMenu
example project出现错误
Console error: Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are identical (check is based on SHA-1 only at this time). Jar mismatch! Fix your dependencies
Fix: 这是由于jar包版本不一致导致的,检查SlidingMenu和Actionbarsherlock中的\libs文件夹里的哪个android-support-v4.jar版本比较新,用新的替换掉其中的老版本. 如果错误还是会出现,就clean项目并重启eclipse.
List of errors: The method getSupportActionBar() is undefined for the type BaseActivity
The method getSupportMenuInflater() is undefined for the type BaseActivity
The method onCreateOptionsMenu(Menu) of type BaseActivity must override or implement a supertype method
The method onOptionsItemSelected(MenuItem) in the type Activity is not applicable for the arguments
The method onOptionsItemSelected(MenuItem) of type BaseActivity must override or implement a supertype method
The method onOptionsItemSelected(MenuItem) of type ResponsiveUIActivity must override or implement a supertype method
Fix:打开SlidingMenu library project里SlidingFragmentActivity这个类并在声明前添加以下代码:
然后,将下面这个父类:
换成Actionbarsherlock里的另外一个父类(如果此时Library没有引用Actionbarsherlock库项目,则先引用之):
附上运行效果图之一:
Actionbarsherlock开源项目下载地址:http://actionbarsherlock.com/download.html
导入步骤如下:
1.将下载的Actionbarsherlock中/actionbarsherlock文件夹复制到workspace(你的项目工作空间),改名为Actionbarsherlock,从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为api14以上。
2.将下载的slidingmenu中/library文件夹复制到workspace(你的项目工作空间),改名SlidingMenu,从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为Google APIs 14以上。或者打开project.properties:target=Google Inc.:Google APIs:14或更高。
3.这样SlidingMenu就可以用在自己项目中了。让我们来运行例子。解压slidingmenu中/example。从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为api14以上。运行看看效果。2.1以上的系统都可以运行。
导入之后可能会出现的问题如下:
1、SlidingMenu library project出现错误
Console error: Unable to resolve target ‘Google Inc.:Google APIs:16.
Fix:进入Properties检查Target sdk是否选择了 Google APIs.
List of errors: ACTION_POINTER_INDEX_MASK cannot be resolved android.
HONEYCOMB cannot be resolved or is not a field
LAYER_TYPE_HARDWARE cannot be resolved or is not a field
LAYER_TYPE_NONE cannot be resolved or is not a field
MATCH_PARENT cannot be resolved or is not a field
The method getLayerType() is undefined for the type View
The method setLayerType(int, null) is undefined for the type View
Fix: 将manifest里面的min sdk version 改为你当前用到的sdk版本,7
2、SlidingMenu
example project出现错误
Console error: Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are identical (check is based on SHA-1 only at this time). Jar mismatch! Fix your dependencies
Fix: 这是由于jar包版本不一致导致的,检查SlidingMenu和Actionbarsherlock中的\libs文件夹里的哪个android-support-v4.jar版本比较新,用新的替换掉其中的老版本. 如果错误还是会出现,就clean项目并重启eclipse.
List of errors: The method getSupportActionBar() is undefined for the type BaseActivity
The method getSupportMenuInflater() is undefined for the type BaseActivity
The method onCreateOptionsMenu(Menu) of type BaseActivity must override or implement a supertype method
The method onOptionsItemSelected(MenuItem) in the type Activity is not applicable for the arguments
The method onOptionsItemSelected(MenuItem) of type BaseActivity must override or implement a supertype method
The method onOptionsItemSelected(MenuItem) of type ResponsiveUIActivity must override or implement a supertype method
Fix:打开SlidingMenu library project里SlidingFragmentActivity这个类并在声明前添加以下代码:
import com.actionbarsherlock.app.SherlockFragmentActivity;
然后,将下面这个父类:
public class SlidingFragmentActivity extends FragmentActivity implements SlidingActivityBase {
换成Actionbarsherlock里的另外一个父类(如果此时Library没有引用Actionbarsherlock库项目,则先引用之):
public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {
附上运行效果图之一:
相关文章推荐
- GitHub上最火的开源项目SlidingMenu导入出错的终极解决方案
- GitHub上最火的开源项目SlidingMenu导入出错的终极解决方案
- GitHub上最火的开源项目SlidingMenu导入出错的终极解决方案
- 导入其它android项目或自己建的android项目运行时出现 Could not found *.apk 终极解决方案
- sqlyog导入导出数据库出错解决方案
- 重装VS 2008出现的加载安装组件出错的终极解决方案
- 整合Struts+Spring+hibernate的时加载出错终极解决方案
- eclipse导入或新建工程出错解决方案
- 重装VS 2008出现的加载安装组件出错的终极解决方案
- OpenGL中x64 debug下bmp图像导入出错解决方案
- javaweb出错笔记:eclipse导入的项目jstl找不到uri的问题解决方案
- MyEclipse2014中导入com.sun.management.OperatingSystemMXBean出错和中文乱码解决方案
- 终极解决方案:在webview中跳转支付宝出错,net::ERR_UNKNOWN_URL_SCHEME
- XenApp 6 license导入报错的终极解决方案
- office 2010 安装时出错 MSXML版本6.10.1129.0终极解决方案
- 试图运行项目时出错: 无法在 Web 服务器上启动调试。您不具备调试此应用程序的权限。此项目的 URL 位于 Internet 区域。有关更多信息,请单击“帮助”。终极解决方案
- 今天遇到IMP-00013: 只有 DBA 才能导入由其他 DBA 导出的文件,通过网上找到解决方案,因此转载,并对另外一种情况进行注释。
- 安装mysql5.7后无法启动,/var/run/mysqld 目录每次重启后都需要手动去创建--终极解决方案