问题描述
我卡的时候,我在Eclipse项目中添加库。我下面这个链接 以及我做的正是它说,但我得到一些reason.Here错误如何happends:
1.I下载支持SDK管理器库。结果
2.I进口它们与现有的Android code到工作区,我在这两个.jar文件构建路径>添加到构建路径preSS。结果
3.然后在该项目(在步骤2中制造)我配置构建路径和我同时检查.jar文件,并取消了Android的依赖,我点击完成。一切都还好现在。结果
但在这里谈到的主要问题=>结果
4。我preSS对我的主项目(myfirstapp)属性,然后单击添加并选择我preSS后库应用和大量的错误的兴起一样的研究解决不了做变量的和我R.id从/根文件夹中突然dissapear
我现在添加一些屏幕拍摄,使之更好地为您。
对不起,我有张贴照片没有声誉。请复制以下
我所有codeS:MainActivity.xml
包com.example.myfirstapp;进口android.content.Intent;
进口android.os.Bundle;
进口android.support.v4.app.Fragment;
进口android.support.v7.app.ActionBarActivity;
进口android.view.LayoutInflater;
进口android.view.Menu;
进口android.view.MenuItem;
进口android.view.View;
进口android.view.ViewGroup;
进口android.widget.EditText;公共类MainActivity扩展ActionBarActivity {
公共最后静态字符串EXTRA_MESSAGE =com.example.myfirstapp.MESSAGE;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main); 如果(savedInstanceState == NULL){
getSupportFragmentManager()调用BeginTransaction()
。新增(R.id.container,新PlaceholderFragment())
。承诺();
}
}
公共无效的sendMessage(查看视图){
意向意图=新意图(这一点,Displaymessageactivity.class);
EDITTEXT的EditText =(EditText上)findViewById(R.id.edit_message);
字符串消息= editText.getText()的toString()。
intent.putExtra(EXTRA_MESSAGE,消息);
startActivity(意向);
} @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){ //充气菜单;如果是present这增加了项目操作栏。
。getMenuInflater()膨胀(R.menu.main,菜单);
返回true;
} @覆盖
公共布尔onOptionsItemSelected(菜单项项){
//处理动作栏项目点击这里。操作栏会
//自动处理上点击主页/向上按钮,只要
//你在AndroidManifest.xml中指定一个父活动。
INT ID = item.getItemId();
如果(ID == R.id.action_settings){
返回true;
}
返回super.onOptionsItemSelected(项目);
} / **
*包含一个简单视图中的占位符片段。
* /
公共静态类PlaceholderFragment扩展片段{ 公共PlaceholderFragment(){
} @覆盖
公共查看onCreateView(LayoutInflater充气器,容器的ViewGroup,
捆绑savedInstanceState){
查看rootView = inflater.inflate(R.layout.fragment_main,集装箱,FALSE);
返回rootView;
}
}}
fragment_main.xml
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=横向>
< EditText上机器人:ID =@ + ID / edit_message
机器人:layout_weight =1
机器人:layout_width =0dp
机器人:layout_height =WRAP_CONTENT
机器人:提示=@字符串/ edit_message/>
<按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=@字符串/ button_send
安卓的onClick =的sendMessage/>
< / LinearLayout中>
的strings.xml
<?XML版本=1.0编码=UTF-8&GT?;
<资源> <字符串名称=APP_NAME> myfirstapp< /串>
<字符串名称=action_settings>设置< /串>
<字符串名称=edit_message>输入消息< /串>
<字符串名称=button_send>发送和LT; /串>
<字符串名称=title_activity_displaymessageactivity> Displaymessageactivity< /串>
<字符串名称=参考hello world>世界,你好<!/串>< /资源>
Displaymessageactivity.xml
包com.example.myfirstapp;进口android.content.Intent;
进口android.os.Bundle;
进口android.support.v4.app.Fragment;
进口android.support.v7.app.ActionBarActivity;
进口android.view.LayoutInflater;
进口android.view.Menu;
进口android.view.MenuItem;
进口android.view.View;
进口android.view.ViewGroup;
进口android.widget.TextView;公共类Displaymessageactivity扩展ActionBarActivity { @覆盖 公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState); //从意图消息
意向意图= getIntent();
字符串消息= intent.getStringExtra(MainActivity.EXTRA_MESSAGE); //创建文本视图
TextView中的TextView =新的TextView(本);
textView.setTextSize(40);
textView.setText(消息); //设置文本视图作为活动布局
的setContentView(TextView的);
} @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){ //充气菜单;如果是present这增加了项目操作栏。
。getMenuInflater()膨胀(R.menu.displaymessageactivity,菜单);
返回true;
} @覆盖
公共布尔onOptionsItemSelected(菜单项项){
//处理动作栏项目点击这里。操作栏会
//自动处理上点击主页/向上按钮,只要
//你在AndroidManifest.xml中指定一个父活动。
INT ID = item.getItemId();
如果(ID == R.id.action_settings){
返回true;
}
返回super.onOptionsItemSelected(项目);
} / **
*包含一个简单视图中的占位符片段。
* /
公共静态类PlaceholderFragment扩展片段{ 公共PlaceholderFragment(){
} @覆盖
公共查看onCreateView(LayoutInflater充气器,容器的ViewGroup,
捆绑savedInstanceState){
查看rootView = inflater.inflate(
R.layout.fragment_displaymessageactivity,集装箱,FALSE);
返回rootView;
}
}}
fragment_displaymessageactivity.xml
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:paddingBottom会=@扪/ activity_vertical_margin
机器人:paddingLeft =@扪/ activity_horizontal_margin
机器人:paddingRight =@扪/ activity_horizontal_margin
机器人:paddingTop =@扪/ activity_vertical_margin
工具:上下文=$ com.example.myfirstapp.Displaymessageactivity PlaceholderFragment> <的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=@字符串/参考hello world/>< / RelativeLayout的>
事情到目前为止,我曾尝试:
1.重新安装Eclipse和Java结果
2.从SDK管理器中搜索重新下载库
3.清洁工程。结果
4.我所有的XML文件开头小写(但MainActivity.xml和Displaymessageactivity.xml必须以大写字母开头)
我尽力,我在这里永远困。我很frustated从谷歌:/结果
每一个帮助非常AP preciated,欢迎!
In step 3, notice that in the Library pane, you should see that the appcompat_v7 already be added (it's added automatically when you create your project follow MyFirstApp instruction, because you have already chosen minSdkVersion=8, not 11) (your second image).
So remove all the added libraries in the Library pane before adding your library (so in your third image it only has android-support-v7-appcompat in Library Pane), then the R.java will not disappear.
这篇关于Eclipse中,添加图书馆项目。我被困的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!