小编Cla*_*reG的帖子

ResourceNotFoundException - 字符串资源ID

07-25 10:15:37.960: E/AndroidRuntime(8661): android.content.res.Resources$NotFoundException: String   resource ID #0x7
07-25 10:15:37.960: E/AndroidRuntime(8661): at android.content.res.Resources.getText(Resources.java:230)
Run Code Online (Sandbox Code Playgroud)

大家好日子.

我试图在文本视图中显示一个整数值,上面的错误显示在LogCat中.

关于这个问题还有其他类似的帖子; 像这样,这个,这个,但没有一个解决方案适合我.

关于问题可能是什么的任何其他想法?

编辑代码:

private static Button btnCancel;
private static Button btnConfirm;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    txtRoomNumber = (EditText)findViewById(R.id.txtRoomNumber);
    btnCancel = (Button)findViewById(R.id.btnCancel);
    btnConfirm = (Button)findViewById(R.id.btnConfirm);

    btnCancel.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v) 
        {
            finish();
            System.exit(0);

        }
    });

    btnConfirm.setOnClickListener(new View.OnClickListener()
    {       
        @Override
        public void onClick(View v) 
        {
            int rmNo = getRoomNumberValue();
            txtTesting.setText(rmNo);
        }
    });
} …
Run Code Online (Sandbox Code Playgroud)

android textview

6
推荐指数
1
解决办法
3364
查看次数

使用 TextViews 将 onClickListener 设置为 TableRow

祝大家有个美好的一天。

我的每一行都有TableLayout三个TextViews。是否仍然可以添加OnClickListener到整行?我想更改所选行的背景颜色。我已经设定OnClickListenerTableRow通过执行以下,但背景颜色不会改变:

   for(int i =0; i < rowAmount; i++)
        {           
            TableRow tr= new TableRow(this);

            TextView rmNo;
            TextView s;
            TextView p;

            rmNo = new TextView(this);
            s = new TextView(this);
            p = new TextView(this);

            rmNo.setText("" + roomNumbers.get(i).toString());
            s.setText("" + statuses.get(i).toString());
            p.setText("" + priorities.get(i).toString());

            tr.addView(rmNo);
            tr.addView(s);
            tr.addView(p);      

            tr.setOnClickListener(new View.OnClickListener() 
            {                   
                @Override
                public void onClick(View v)
                {
                    tr.setBackgroundColor(color.holo_blue_light);
                }
            });

            tblContent.addView(tr);
        }

    }
Run Code Online (Sandbox Code Playgroud)

我正在以编程方式创建 TableRows 和 TextViews,因为它们的数据是从数据库中检索的。

这是 XML:

<ScrollView
    android:id="@+id/scroll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tblTitles"> …
Run Code Online (Sandbox Code Playgroud)

android tablelayout tablerow android-tablelayout

4
推荐指数
1
解决办法
2万
查看次数

未在服务中实现接口成员

首先,如果对这个问题的引用不正确,我会道歉.

我正在开发一个三层MVC 3应用程序.在业务层中,我需要创建一个服务,该服务将调用数据访问层,以便检索现有城镇的列表.

我的ITown界面如下;

[ServiceContract]
public interface ITown
{
    [OperationContract]
    IEnumerable<Town> GetAllTowns();
}
Run Code Online (Sandbox Code Playgroud)

Town.svc.cs,我插入如下;

public class Town : ITown
{
    public IEnumerable<Common.Town> GetAllTowns()
    {
        return new DATown().GetAllTowns();
    }
}
Run Code Online (Sandbox Code Playgroud)

问题出在上面的代码中.我Town在类声明中遇到错误public class Town : ITown.

'Business.Town' does not implement interface member 'Business.ITown.GetAllTowns()'. 
'Business.Town.GetAllTowns()' cannot implement 'Business.ITown.GetAllTowns()'
because it does not have the matching return type of 'System.Collections.Generic.IEnumerable<Business.Town>'.
Run Code Online (Sandbox Code Playgroud)

这是我的内容DATown;

public class DATown : Connection
{
    //Constructor
    public DATown()
        :base()
    { …
Run Code Online (Sandbox Code Playgroud)

c# wcf asp.net-mvc-3

2
推荐指数
1
解决办法
563
查看次数

ListView中的CheckBox多选

大家好日子.

我有一个列表视图,每个textview附近都有复选框.当我勾选一个复选框并向下滚动时,也会检查随机的其他复选框.我在这里读过这篇文章和其他几篇文章,他们都说每个复选框的状态都需要保存在一个布尔列表中 getView().我该怎么做呢?

谢谢.

编辑代码:

这是适配器的代码,也包含getView()方法.

public class MyCustomAdapter extends BaseAdapter
{
    public ArrayList<Error> list;
    private Context mContext;
    private LayoutInflater mInflator;

    public MyCustomAdapter(Context context, int textViewResourceId, ArrayList<Error> list)
    {
        this.list = list;
        this.mContext = context;
        mInflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

@Override
public int getCount() 
{
    return list.size();
}

@Override
public Error getItem(int position) 
{
    return list.get(position);
}

@Override
public long getItemId(int position) 
{
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) …
Run Code Online (Sandbox Code Playgroud)

android android-listview

1
推荐指数
1
解决办法
2万
查看次数

使用Linq获取Top x产品

我需要使用Linq to Entities获得前10名记录.

我需要将返回的结果绑定到GridView如下"

Product Name  |   Product Description  |   Number of Items Sold

Item 1        |   Item 1 Description   |           24
Run Code Online (Sandbox Code Playgroud)

如上所述,物品需要按顺序存储,从销售的大多数商品开始.

我试了几个例子,比如这个,这个,跟着例子在这里.

以下是我到目前为止所尝试的内容:

public IQueryable GetTopTenProducts(DateTime startDate, DateTime endDate)
{
    return
        (from p in this.Entities.Product
         join pro in this.Entities.ProductOrder on p.ID equals pro.ProductID
         join o in this.Entities.Order on pro.OrderID equals o.ID
         where o.DateOfOrder >= startDate && o.DateOfOrder <= endDate
         select new
         {
             Product = p,
             Quantity = pro.Qty,
             ProductName = …
Run Code Online (Sandbox Code Playgroud)

c# linq linq-to-entities linq-query-syntax

0
推荐指数
1
解决办法
336
查看次数