我在包含唯一ID的整数上有一个ArrayList。
我有这个方法来填充listview。
public void getDataDetails(int id)
{
Cursor c = db.getData(id);
String[] from = new String[]{ID, name};
int[] to = new int[]{R.id.layout_id, R.id.layout_name};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.layout, c, from, to, 0);
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
在我的onCreate方法中,我有这个代码。可变数据是我的ArrayList,其值为1和2。
listview= (ListView) findViewById(R.id.listView);
for (int x=0; x < data.size(); x++)
{
getDataDetails(data.get(x));
}
我的问题是,当x = 2时,显示的唯一数据是数据。应该有两个listview包含x = 1和x = 2的数据。有什么帮助吗?
答案 0 :(得分:1)
将其放在def build_shift_dict(self, shift):
dict1 = {}
str1 = string.ascii_uppercase
for s in str1:
if (ord(s)+shift-65) < 26 :
dict1[s] = chr(ord(s)+shift)
elif (ord(s)+shift-65) >= 26 :
dict1[s] = chr(ord(s)+shift-26)
str1 = string.ascii_lowercase
for s in str1:
if (ord(s)+shift-97) < 26 :
dict1[s] = chr(ord(s)+shift)
elif (ord(s)+shift-97) >= 26 :
dict1[s] = chr(ord(s)+shift-26)
return dict1
def apply_shift(self, shift):
msg = self.get_message_text()
newMsg = ""
dict1 = self.build_shift_dict(shift)
for i in range(len(msg)):
if dict1.has_key(msg[i]):
newMsg += dict1.get(msg[i])
else:
newMsg += msg[i]
return newMsg
onCreate()