这是我的代码:
public class MainActivity extends Activity {
private ComponentName mService;
private Servicio serviceBinder;
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
serviceBinder = ((Servicio.MyBinder)service).getService();
}
public void onServiceDisconnected(ComponentName className) {
serviceBinder = null;
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent bindIntent = new Intent(this, Servicio.class);
bindService(bindIntent, mConnection, Context.BIND_AUTO_CREATE);
}
@Override
protected void onStart() {
serviceBinder.somethingThatTakesTooMuch();
super.onStart();
}
public class Servicio extends Service {
private final IBinder binder = new MyBinder(); …Run Code Online (Sandbox Code Playgroud) 我有一个名为NoteViewextend 的自定义类FrameLayout.以前,我刚刚使用该库存LinearLayout并且已经构建了一个XML布局,我希望通过添加整个层次结构(以及其他一些叠加视图,这就是我需要framelayout的原因)来重用NoteView.
问题是我无法弄清楚如何膨胀XML并将其添加到NoteView从内部NoteView类.我可以在初始化完成后添加它,但是我希望能够在我NoteView从XML实例化或扩充时自动添加该层次结构并自动添加它.
如何FrameLayout通过从NoteView类本身添加XML来扩展XML 扩展?
我在spring-mvc做了一个用户问题.
我的模型具有以下属性:
private Long id;
private String password;
private String username;
private Collection<Authority> myAuthorities;
private boolean isAccountNonExpired;
private boolean isAccountNonLocked;
private boolean isCredentialsNonExpired;
private boolean isEnabled;
Run Code Online (Sandbox Code Playgroud)
我解决了如何Authority在这个问题中展示课程.
现在我愿意我的表单能够有第二个密码字段来确认用户是否正确输入了密码.
我不想confirmPassword在模型中添加属性,所以我的问题是如何以最好的方式解决这个问题.
编辑:
一切都在使用axtavt的答案,但我错过了一种验证方法.我的控制器中有以下方法,但即使我放置了一个@Validate
ApplicationUserFormValidator未调用的方法.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView create(Model model,
@Valid @ModelAttribute ApplicationUserForm applicationUserFrom,
BindingResult result) {
ModelAndView modelAndView = new ModelAndView();
if (result.hasErrors()) {
modelAndView.setViewName(USER_CREATE_FORM);
} else {
modelAndView.setViewName(REDIRECT_TO_USER_LIST);
modelAndView.addObject(USER_FORM_MESSAGE, USER_FORM_ADD_SUCCESSFUL);
applicationUserService.save(applicationUserFrom.getUser);
}
return modelAndView;
}
Run Code Online (Sandbox Code Playgroud) 我想通过我的应用程序拨打电话.我正在使用该代码:
private void call7() {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:281212114"));
startActivity(callIntent);
} catch (ActivityNotFoundException e) {
Log.e("CALL", "Call failed", e);
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,我怎样才能在通话视图中输入电话号码,但只有在用户按下通话按钮时才拨打电话?
我正在开发一个通用的Android应用程序,我需要检查应用程序是在平板电脑还是在手机中运行.有没有办法做到这一点?
昨天我正在阅读一篇名为:Scala Experience如何改进我们的Java开发的论文.
在对象初始化部分,它说:
用于实例化对象的惯用Scala技术(不通过构造函数参数公开所有相关参数)是创建一个带有初始化块的匿名子类,该块调用其他语句[Odersky et al.]:
我一直在做一些测试:
class B {
var x1: String = "B"
def setText(text: String) {
x1 = text
}
override def toString = x1
}
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么我能这样做:
scala> new B{setText("new Text")}
res23: B = new Text
Run Code Online (Sandbox Code Playgroud)
但我做不到:
scala> new B{ setText "new Text" }
<console>:1: error: ';' expected but string literal found.
new B{ setText "new Text" }
^
Run Code Online (Sandbox Code Playgroud) 添加<item>170,000</items>后string.xml.它在构建工作空间时变得如此缓慢,我增加了我的堆空间和jvm内存,但仍然很慢我在每次编辑之后必须等待4个小时才能在运行程序之前保存在eclipse上.
有解决方案吗?(我在ubuntu 11.10上使用gnome 3.0).
我是android的新手并且遇到了问题.
我想知道如何以编程方式强制关闭应用程序并再次重新启动它.我正在尝试这个,因为我真的被困了,OutOfMemmoryError我想释放内存并重新启动应用程序.
如果我错了,请指导我.
跑步Robotium很慢.
adb shell monkey ...
Run Code Online (Sandbox Code Playgroud)
运行速度非常快,GUI只是在屏幕上闪烁.因为我是新手,Robotium我想知道这是否正常?
我知道Android应用程序只有一个UI线程.
运行时是否强制所有UI调用都是从该线程进行的,还是由程序员决定是否确保没有从其他线程进行UI调用?