我需要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) 我有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)
其中矢量A和B分别是行和列和我有数据C.任何帮助,将不胜感激.
我有
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].
提前致谢.