用切片的ListView与J.夏基的SeparatedListAdapter许可问题 [英] License problem using sectioned ListView with J. Sharkey's SeparatedListAdapter
问题描述
大的解释(更好的安全...),以粗体显示,如果你不想把它读完了问题。非常感谢您的帮助!
big explanation (better safe...), question in bold if you don't want to read it all. Thanks a lot for your help!
我有一个的ListView
一个应用程序,以及两个自定义XMLS。一个是一个单一的TextView,对于标头。另外有3个TextViews和3 ImageViews的重新present数据。
I have an app with a ListView
, and two custom XMLs. One is a single TextView, for the headers. The other has 3 TextViews and 3 ImageViews that represent the data.
由于大多数人都知道,杰夫·夏基已经中有一个的很聪明的(恕我直言)解决方案( SeparatedListAdapter
),它允许类的工作,无需修改,以ImageViews。虽然接受字符串
S,我可以提供的valueOf提拉INT资源
,它会看着办吧。大,见code和屏端(他的课不是在这里为简便起见)。
As most of you know, Jeff Sharkey already has a very clever (imho) solution (SeparatedListAdapter
), which allows the class to work, without modifications, with ImageViews. Although it accepts String
s, I can provide the valueOf
of the drawable int resources, and it will figure it out. Great, see code and screen at end (his class not here for simplicity).
问题是,我的项目,我已经给了一叠内部,私有code一起工作。而夏基的code是GPLv3的,这就排除了使用我自己的code的可能性。因此,也许你可以知道一个解决办法,让我没有我的其他code被吸引到GPL的力量链接到code。我不讨论它的政治,所以我AP preciate如果你不知道。再说,我不回避,我回避它合法。
The problem is that, for my project, I've been given a stack of in-house, proprietary code to work with. And Sharkey's code is GPLv3, which rules out the possibility of me using his code. So maybe you could know a solution that would allow me to link to that code without my other code being "attracted" to the force of the GPL. I'm not discussing the politics of it, so I appreciate if you don't. Besides, I'm not circumventing, I'm avoiding it legally.
现在,我已经能够找到 CWAC合并,这是翔升2但到目前为止,我不能地图的字符串,可绘制自定义TextViews和ImageViews在自定义XML布局。此外,该示例应用程序使用了完全不同的方法是什么,我想我需要远程
Right now, I've been able to find cwac-merge, which is ASL 2. But so far I couldn't "map" the strings and drawables to custom TextViews and ImageViews in a custom XML layout. Also, the example app uses a completely different approach to what I think I remotely need.
如果你要不要看什么,我提出来,看看 SeparatedListAdapter
及以下我的课。对于CWAC合并,它的力量将关闭不管是什么,所以我不会打扰张贴。
In case you care to see what I'm up to, see SeparatedListAdapter
and my class below. For cwac-merge, it force closes no matter what, so I won't bother posting.
package com.uitests;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;
public class TestActivity extends ListActivity {
public final static String ITEM_TITLE = "title";
public final static String ITEM_STATE = "state";
public final static String ITEM_TEMPERATURE = "temperature";
public final static String ITEM_UP = "up";
public final static String ITEM_DOWN = "down";
public final static String ITEM_LEVEL = "level";
public Map<String,?> createItem(
String title, String state, String temperature,
String upImage, String downImage, String levelImage) {
Map<String,String> item = new HashMap<String,String>();
item.put(ITEM_TITLE, title);
item.put(ITEM_STATE, state);
item.put(ITEM_TEMPERATURE, temperature);
item.put(ITEM_UP, upImage);
item.put(ITEM_DOWN, downImage);
item.put(ITEM_LEVEL, levelImage);
return item;
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// THIS IS JUST AN EXAMPLE TO POPULATE THE LIST FOR STACKOVERFLOW!
List<Map<String,?>> controlA = new LinkedList<Map<String,?>>();
controlA.add(createItem(
"Monitor 001AK",
"Functional",
"27",
String.valueOf(R.drawable.ic_up),
String.valueOf(R.drawable.ic_down_off),
String.valueOf(R.drawable.ic_level07)));
// MORE .adds HERE
List<Map<String,?>> controlB = new LinkedList<Map<String,?>>();
controlB.add(createItem(
"Monitor 003CK",
"Functional",
"29",
String.valueOf(R.drawable.ic_up),
String.valueOf(R.drawable.ic_down_off),
String.valueOf(R.drawable.ic_level07)));
// MORE .adds HERE
SeparatedListAdapter adapter = new SeparatedListAdapter(this);
adapter.addSection(
"Control 1",
new SimpleAdapter(
this,
controlA,
R.layout.equip_row,
new String[] {
ITEM_TITLE,
ITEM_STATE,
ITEM_TEMPERATURE,
ITEM_UP,
ITEM_DOWN,
ITEM_LEVEL },
new int[] {
R.id.tide_row_title, // TextView
R.id.tide_row_state, // TextView
R.id.tide_row_temperature, // TextView
R.id.tide_row_img_up, // ImageView
R.id.tide_row_img_down, // ImageView
R.id.tide_row_img_level } // ImageView
)
);
adapter.addSection(
"Control 2",
new SimpleAdapter(
this,
controlB,
R.layout.equip_row,
new String[] {
ITEM_TITLE,
ITEM_STATE,
ITEM_TEMPERATURE,
ITEM_UP,
ITEM_DOWN,
ITEM_LEVEL },
new int[] {
R.id.tide_row_title,
R.id.tide_row_state,
R.id.tide_row_temperature,
R.id.tide_row_img_up,
R.id.tide_row_img_down,
R.id.tide_row_img_level }
)
);
this.getListView().setAdapter(adapter);
}
}
所有简单的结果在这个伟大的屏幕:
all that simplicity results in this great screen:
推荐答案
OK,我设法使它工作使用的 CWAC合并。我从人得到了帮助这里。
OK, I managed to make it work using cwac-merge. I got help from people here.
我不会推倒重来,这样你就可以阅读所有的信息有(其中包括使用了code)。如果需要,我可以澄清。只要问,我会帮助你。
I won't reinvent the wheel, so you can all read the information there (including the code used). I can clarify if needed. Just ask and I'll help.
这篇关于用切片的ListView与J.夏基的SeparatedListAdapter许可问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!