小编Bat*_*ven的帖子

更改Android中所选列表项的布局

我需要ListView为所选行创建一个并显示更详细的布局,以便向客户显示更多信息.我尝试的是以下内容:

newsListView.setAdapter(new NewsListAdapter(this, news));
newsListView.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        //Here I tried to change layout of this row only
        view = inflater.inflate(R.layout.listitem_news_selected, null);
        TextView info = (TextView) view.findViewById(R.id.info);

        NewsData news = (NewsData) parent.getItemAtPosition(position);
        info.setText(news.getInfo());
    }
});
Run Code Online (Sandbox Code Playgroud)

这是NewsListAdapter:

public class NewsListAdapter extends BaseAdapter {

    List<NewsData> items;
    Activity context;

    /* private view holder class */
    private class ViewHolder {
        TextView title;
        ImageView image;
    } …
Run Code Online (Sandbox Code Playgroud)

android listview adapter android-listview

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

R - 从3个原始向量创建矩阵

我有3个向量如下:

A <- c("A", "B", "C", "D", "E")
B <- c("1/1/1", "1/1/1", "2/1/1", "2/1/1", "3/1/1")
C <- c(1, 1, -1, 1, -1)
Run Code Online (Sandbox Code Playgroud)

我想使用这3个向量创建如下的矩阵:

- 1/1/1 2/1/1 3/1/1
A   1    0     0
B   1    0     0
C   0    -1    0
D   0    1     0
E   0    0     -1
Run Code Online (Sandbox Code Playgroud)

其中矢量AB分别是行和列和我有数据C.任何帮助,将不胜感激.

r matrix

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

将类型a转换为char

我有

data Dictionary a = Empty
                  | Branch (a, Bool, Dictionary a) (Dictionary a)
                  deriving (Ord, Eq)

instance Show (Dictionary a) where show = showDict

showDict (Branch (val, e, dict) dict2) = "My dict is : " ++ val 
Run Code Online (Sandbox Code Playgroud)

我知道这肯定是错的,但我找不到如何写这个.在showDict函数中,val的类型是一个但是期望的类型是[Char].

提前致谢.

haskell

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

标签 统计

adapter ×1

android ×1

android-listview ×1

haskell ×1

listview ×1

matrix ×1

r ×1