因此,我有一个包含2 ListView个小部件的活动,当您在第一个中选择一个值时,第二个将填充与第一个中的选择相关的值ListView.这个机制没有问题,但现在我希望用户选择保持突出显示.我已经阅读了与此主题相关的一个很好的问题,似乎有很多方法可以实现这一点但是在尝试了4-5之后,我仍然无法让它工作.
我已经ListView使用android:listSelector="#CCCCCC"XML属性在第二个工作了,但是一旦OnItemClickListener引入混合(这就像我第一次使用的那个ListView),这似乎被擦干净了.
到目前为止,这是我得到的:
自定义OnItemClickListener我发现浏览关于这个主题的各种答案(稍微修改它,以便它加载我的信息第二个ListView):
private class ItemHighlighterListener implements OnItemClickListener {
private View oldSelection = null;
public void clearSelection() {
if(oldSelection != null) {
oldSelection.setBackgroundColor(android.R.color.transparent);
}
}
public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
clearSelection();
oldSelection = view;
view.setBackgroundDrawable(view.getContext().getResources().getDrawable(R.drawable.list_selector));
loadClubs(mXMLPortalOptions.getRegion(pos).getId());
mClubList.setAdapter(new ArrayAdapter<String>(getApplicationContext(), R.layout.list_item_white, mClubs));
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的list_selector.xml档案:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"><shape>
<solid android:color="#CCCCCC" />
</shape></item>
<item android:state_selected="false"><shape>
<solid …Run Code Online (Sandbox Code Playgroud) 我正在为我的Android应用程序开发一个帐户管理活动,但是我很难弄清楚为什么来自微调器的setSelection()方法不会触发附加到所述Spinner的OnItemSelectedListener.
这就是我目前所拥有的;
onCreate()方法:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_management);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
retreiveLanguage();
initializeUI();
// Vérification si l'usager est déjà connecté
Globals appState = ((Globals) this.getApplication());
boolean userLoggedIn = appState.isUserLoggedIn();
boolean userInfoAvailable = appState.isUserInfoAvailable();
if (userLoggedIn && userInfoAvailable) {
fillUI();
}
}
Run Code Online (Sandbox Code Playgroud)
来自initializeUI()方法的相关行,该方法在Activity的创建中调用,该方法显示Spinner与Listener的绑定:
/** OnItemSelectedHandler for the Country Spinner */
mCountrySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
Log.i(TAG, "onCountrySelected() was called, position : " + pos);
mProvinces = new ArrayList<String>();
mProvincesCode …Run Code Online (Sandbox Code Playgroud) 好吧所以我只是因为客户需求而将我转换为我正在进行的活动中直接可见TimePickerDialog的TimePicker小部件.
问题是,当我按下任何箭头时TimePicker,我得到一个NullPointerException.
只是为了澄清,TimePicker在onCreate()我的Activity 的方法中除了这一行之外没有任何代码附加了什么:
((TimePicker) findViewById(R.id.time_picker)).setIs24HourView(true);
我在Google论坛上发现了关于此问题的这篇文章,但帮助不大.
这是我的错误日志,我遗憾地认为这不会有太多帮助.
只有在ICS(Android 4.0 +)中进行测试时才会出现此问题.有没有人能够解决这个问题?
android nullpointerexception timepicker android-4.0-ice-cream-sandwich
有人可以在运行我的Android应用程序时向我解释以下警告的含义(警告按给定的顺序输出):
04-17 15:29:11.693: I/dalvikvm(4442): DexOpt: access denied from Lcom/kirona/iclient/db/core/services/impl/MiscDatabaseModuleDaoImpl; to field Lcom/kirona/iclient/database/common/impl/AbstractDatabaseModuleDao;.logger
04-17 15:29:11.653: W/dalvikvm(4442): VFY: unable to resolve static field 30 (logger) in Lcom/kirona/iclient/db/core/services/impl/MiscDatabaseModuleDaoImpl;
04-17 15:29:11.653: D/dalvikvm(4442): VFY: replacing opcode 0x62 at 0x0001
04-17 15:29:11.693: D/dalvikvm(4442): VFY: dead code 0x0046-006e in Lcom/kirona/iclient/db/core/services/impl/MiscDatabaseModuleDaoImpl;.getSequenceNextVal (Ljava/lang/String;)J
Run Code Online (Sandbox Code Playgroud)
该应用程序似乎运行正常,但我需要了解这个问题,因为我们有更复杂的应用程序,类似的错误导致dalvikvm崩溃.
我有一个关于Criteria方法的问题,与数据库的一对多关系,'one'是" account ",'many'是" sites ",当我使用的CreateCriteria()东西不对时.
像这样: SessionFactory.OpenSession().CreateCriteria(typeof(Account)).List().Count();
在它运行之前,我认为SQL应该是SELECT COUNT(*) FROM table,但SQL是SELECT id, siteurl...FROM table.那有什么不对呢?我该如何解决?
和First()方法应该是SELECT TOP1 ...FROM table,但它是SELECT ...FROM table
我是Nhiberate新秀,请帮助我.
我是一个java新手,我正在开发一个带菜单,scrollpane和textarea的简单应用程序.
到目前为止,我已经在表单上得到了我想要的所有内容,但是当我启动我的应用程序时,滚动窗格/文本区域将不会显示,直到我重新调整窗口.
我尝试使用其他论坛上建议的重绘方法来解决类似问题,但它没有用,也许我没有正确使用它:S
这是我的班级:
public class FenetreEditeur {
public static void main(String[] args){
FenetreEditeur f = new FenetreEditeur();
}
public FenetreEditeur(){
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setSize(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
initMenuBar(frame);
JTextArea areaMain = new JTextArea();
JScrollPane scrollPane = new JScrollPane(areaMain);
frame.add(scrollPane);
}
private void initMenuBar(JFrame frame){
JMenuBar menu = new JMenuBar();
JMenu revision = new JMenu("Revision");
JMenuItem statistiques = new JMenu("Statistiques");
JMenuItem grammaire = new JMenu("Grammaire et orthographe");
JMenuItem analyse = new JMenu("Analyse Automatique");
menu.add(revision);
revision.add(statistiques);
revision.add(grammaire);
revision.add(analyse);
frame.setJMenuBar(menu); …Run Code Online (Sandbox Code Playgroud) android ×4
android-4.0-ice-cream-sandwich ×1
criteria ×1
dalvik ×1
highlighting ×1
java ×1
listview ×1
nhibernate ×1
spinner ×1
swing ×1
timepicker ×1