在我的项目中,我使用了动作栏sherlock库.我想在操作栏中制作后退按钮我使用下面的代码
getSupportActionBar().setHomeButtonEnabled(true);
Run Code Online (Sandbox Code Playgroud)
和
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
default:
return super.onOptionsItemSelected(item);
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
每件事情都很好,但后面的箭头(图标左侧)没有显示.我也想显示Back Arrow.谁能告诉我我做错了什么.
我在hibernate中使用此代码.
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="RightID", unique=true, nullable=false)
Run Code Online (Sandbox Code Playgroud)
问题是,当我删除一行时,'RightId'不会按顺序保留.我想要类似的东西,hibernates应该检查id,如果缺少一些id值,它必须将该值赋予'RightsId'否则继续正常
我有在我从数据库中获取数据的情况下,我想它上溯造型到ArrayList of objects,然后其向下转换到不同的自定义的ArrayList即List<User>,List<Groups>等等.
我的问题是向上转换为对象,然后向下转换为ArrayList,这将是成本,是高效还是良好的做法.
EDITED
List<User>, List<Groups>我不想获取数据等,而是根据我的需要获取数据ArrayList<objetcs>,我会将数据转发给ArrayList<User>, ArrayList<Groups>以后.
这是我的对话框代码,如果编辑文本中的文本大小大于5,我想禁用正按钮,如果大小<= 5则启用它
private void myDialog(String title) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
// Get the layout inflater
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.new_dialog, null);
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(dialogView);
final EditText dialogEdittext = (EditText) dialogView.findViewById(R.id.dialog_editText);
final TextView dialogMessage = (TextView) dialogView.findViewById(R.id.dialog_limit);
dialogEdittext.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override …Run Code Online (Sandbox Code Playgroud) 我有一个表'users',有很多列,其中两个是'Username','Password'用户名是主键列
我想更新用户名的密码.这是我的代码它工作正常(没有错误或异常)但没有更新密码.
我是Hibernate的新手,对它的语法知之甚少.请帮我
String query = "UPDATE users SET Password = '"+ newPassword +"' WHERE Username = '"+ login.getUsername() + "'";
session.createSQLQuery(query);
Run Code Online (Sandbox Code Playgroud)
login.getUsername()正确获取所需的用户名
其余代码工作正常的问题在于上面的代码.
我打造了相当多的障碍ActionBar.
我现在遇到的问题ActionView是扩展时的徽标/图标.由于某种原因,它不使用此处可绘制的徽标,但应用程序图标可绘制.我希望这个消失或者设置为我自己的drawable.我尝试onMenuItemActionCollapse()使用setIcon()功能直接设置图标ActionBar,没有运气.还尝试在那里设置家庭和徽标的东西.
任何想法如何解决这个问题?
我正在使用SearchView,它工作正常,但只是setOnCloseListener没有工作; 这是我的代码
import com.actionbarsherlock.widget.SearchView.OnCloseListener;
Run Code Online (Sandbox Code Playgroud)
和
searchView.setOnCloseListener(new OnCloseListener() {
@Override
public boolean onClose() {
Toast.makeText(context, "close", Toast.LENGTH_SHORT).show();
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
**编辑****
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Used to put dark icons on light action bar
//Create the search view
final SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setQueryHint("Search");
searchView.setIconifiedByDefault(true);
//search button
menu.add(Menu.NONE,Menu.NONE,1,"Search a word")
.setIcon(R.drawable.abs__ic_search_api_holo_light)
.setActionView(searchView)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
MenuItem sView = menu.findItem(1);
sView.setOnActionExpandListener(this);
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
adopter.getFilter().filter(null);
Toast.makeText(getApplicationContext(), "collapse", Toast.LENGTH_LONG).show(); …Run Code Online (Sandbox Code Playgroud) HashMap roleRightsID = new HashMap();
有没有类似于HashMap的数据结构,我可以在其中添加重复的键
例如
美国,纽约美国,洛杉矶美国,芝加哥巴基斯坦,拉合尔巴基斯坦,卡拉奇
等等
我想要两个单独的事件长按单击向下和长按.我怎样才能在Android中执行此操作?
我试过的内容如下
public class FfwRewButton extends ImageButton {
public interface ButtonListener {
void OnLongClickDown(View v);
void OnLongClickUp(View v);
}
private ButtonListener mListener;
private boolean mLongClicked = false;
public FfwRewButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setFocusable(true);
setLongClickable(true);
}
public FfwRewButton(Context context) {
this(context, null);
}
public FfwRewButton(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.imageButtonStyle);
}
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
Log.d("my listener", "long press");
mLongClicked = true;
mListener.OnLongClickDown(this);
return super.onKeyLongPress(keyCode, event);
}
@Override
public …Run Code Online (Sandbox Code Playgroud)