我的Android应用程序无法找到XML文件中声明按钮 [英] My Android application cannot find buttons declared in the XML file
本文介绍了我的Android应用程序无法找到XML文件中声明按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序工作正常在XML对象之前读,但现在我已经加入到两个按钮和一个TextView它它有发现他们有问题。
所以我添加了三个对象有我的应用程序的更多的控制和活动类无法找到他们。
公共类TVListingTestActivity扩展活动实现OnClickListener
{
私有静态最后弦乐TAG =对myApp;私人的EditText InfoView的;
私人字符串结果;
私人字符串十足;公众诠释计数;最后上下文的背景下=这;私人的LinkedList<窗口小部件>一个列表;
私人的LinkedList<串GT; StringList的;
私人的LinkedList<按钮和GT;纽扣;私人按钮forwardDay;
私人按钮backDay;
私人TextView中显示;私人INT dayParse = 0;
私人字符串tvListingURL;@覆盖
公共无效的onCreate(捆绑savedInstanceState)
{
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
StringList的=新的LinkedList<串GT;(); InfoView的=(的EditText)findViewById(R.id.infoView);
tvListingURL =http://bleb.org/tv/data/rss.php?ch=bbc1_scotland&day=\"+dayParse; forwardDay =(按钮)findViewById(R.id.forwardbutton);
backDay =(按钮)findViewById(R.id.backbutton);
显示=(的TextView)findViewById(R.id.displayview);
资源似乎显示了在R文件,所以我不明白是什么问题。有没有人encounterd这样的事以前?
包org.me.myandroidstuff;最终大众R级{
公共静态final类数组{
公共静态最终诠释表明= 0x7f040000;
}
公共静态final类ATTR {
}
公共静态final类绘制{
公共静态最终诠释图标= 0x7f020000;
}
公共静态最后的类ID {
公共静态最终诠释回来= 0x7f060002;
公共静态最终诠释cspinner = 0x7f060007;
公共静态最终诠释dialog_info = 0x7f060000;
公共静态最终诠释的InfoView = 0x7f060003;
公共静态最终诠释主要= 0x7f060004;
公共静态最终诠释main_page = 0x7f060006;
公共静态最终诠释mainll = 0x7f060005;
公共静态最终诠释提醒= 0x7f060001;
}
公共静态最后的客舱布局{
公共静态最终诠释dialog_info = 0x7f030000;
公共静态最终诠释主要= 0x7f030001;
公共静态最终诠释main_page = 0x7f030002;
}
公共静态最后类字符串{
公共静态最终诠释APP_NAME = 0x7f050001;
公共静态最终诠释你好= 0x7f050000;
}
}
解决方案
删除 android.R
从Java中文件导入。
My application was working fine before reading in XML objects but now I have added to the two buttons and a textview to it it's having a problem finding them.
So I added the three objects there for more control of my application and the activity class cannot find them
public class TVListingTestActivity extends Activity implements OnClickListener
{
private static final String TAG = "myApp";
private EditText infoView;
private String result;
private String full;
public int count;
final Context context =this;
private LinkedList<Widget> aList;
private LinkedList<String> stringList;
private LinkedList<Button> buttons;
private Button forwardDay;
private Button backDay;
private TextView display;
private int dayParse= 0;
private String tvListingURL;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
stringList = new LinkedList<String>();
infoView= (EditText) findViewById(R.id.infoView);
tvListingURL = "http://bleb.org/tv/data/rss.php?ch=bbc1_scotland&day="+dayParse;
forwardDay=(Button)findViewById(R.id.forwardbutton);
backDay=(Button)findViewById(R.id.backbutton);
display=(TextView)findViewById(R.id.displayview);
The resources seem to be showing up in the R file so I cannot understand what the problem is. Has anyone encounterd anything like this before?
package org.me.myandroidstuff;
public final class R {
public static final class array {
public static final int shows=0x7f040000;
}
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int back=0x7f060002;
public static final int cspinner=0x7f060007;
public static final int dialog_info=0x7f060000;
public static final int infoView=0x7f060003;
public static final int main=0x7f060004;
public static final int main_page=0x7f060006;
public static final int mainll=0x7f060005;
public static final int reminder=0x7f060001;
}
public static final class layout {
public static final int dialog_info=0x7f030000;
public static final int main=0x7f030001;
public static final int main_page=0x7f030002;
}
public static final class string {
public static final int app_name=0x7f050001;
public static final int hello=0x7f050000;
}
}
解决方案
Delete android.R
from your imports in java file.
这篇关于我的Android应用程序无法找到XML文件中声明按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文