在android(java)中,当你使用函数getlatitude()等获得当前纬度和经度时,你得到十进制格式的坐标:
纬度:24.3454523经度:10.123450
我想把它变成度数和小数分钟看起来像这样:
纬度:40°42'51"N经度:74°00'21"W
今天我更新了我的Android Studio,无论我做什么,我都会收到这个错误.我从github导入了一个项目,一切运行顺利,直到我现在更新,我一直收到这个错误:
错误:(31,0)未找到Gradle DSL方法:'jniDebugBuild()'可能的原因:
任何人都可以帮忙吗?
嗨,我只想知道是否可以禁止用户输入的第一个数字为"0".
<EditText
android:id="@+id/editText1"
android:layout_width="50dp"
android:layout_height="35dp"
android:layout_marginBottom="2dp"
android:maxLength="2"
android:inputType="number"
android:digits="123456789">
<requestFocus />
</EditText>
Run Code Online (Sandbox Code Playgroud)
但是,使用此代码可以防止用户输入"0",但我只希望第一个数字不是"0"
我正在编写一个包含登录详细信息(用户名和密码)的应用程序
我希望这样做,以便当用户关闭应用程序并稍后再次启动它时,他/她不必再次输入他/她的用户名和密码.
所以这是我的代码到目前为止.不幸的是,它似乎不记得密码和用户名:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mPrefs = getSharedPreferences(PREFS, 0);
final CheckBox rememberMeCbx = (CheckBox)findViewById(R.id.saveLoginCheckBox);
boolean rememberMe = mPrefs.getBoolean("rememberMe", false);
if (android.os.Build.VERSION.SDK_INT > 9)
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
mXmlRpcClient = new XMLRPCClient(mXmlRpcUri);
// Set up the login form.
//mUsername = getIntent().getStringExtra(EXTRA_EMAIL);
mUsernameView = (EditText) findViewById(R.id.username);
mUsernameView.setText(mUsername);
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id,
KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) { …Run Code Online (Sandbox Code Playgroud) 我想制作一款使用Google Maps Android API V2的应用.所以我在互联网上搜索了教程,我找到了很多有用的教程.他们在教程中说,要使用Google Maps Android API V2,我必须获得一个Google Maps API密钥.好到目前为止一切顺利.
我的问题是
我想知道从ViewModel在视图中显示某种消息的最佳方法是什么。我的ViewModel正在进行POST调用,“ onResult”我想向包含特定消息的用户弹出一条消息。
这是我的ViewModel:
public class RegisterViewModel extends ViewModel implements Observable {
.
.
.
public void registerUser(PostUserRegDao postUserRegDao) {
repository.executeRegistration(postUserRegDao).enqueue(new Callback<RegistratedUserDTO>() {
@Override
public void onResponse(Call<RegistratedUserDTO> call, Response<RegistratedUserDTO> response) {
RegistratedUserDTO registratedUserDTO = response.body();
/// here I want to set the message and send it to the Activity
if (registratedUserDTO.getRegisterUserResultDTO().getError() != null) {
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
我的活动:
public class RegisterActivity extends BaseActivity {
@Override
protected int layoutRes() {
return R.layout.activity_register;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState); …Run Code Online (Sandbox Code Playgroud) 大家好,有没有一种方法可以让我将我的申请翻译成另一种语言,而不需要花钱请其他人为我翻译?我在 google play 中看到有一个选项建议我上传 strings.xml 文件,他们会为我翻译它。
所以我试图在我的活动中膨胀布局,但我不断收到此错误"无法解决方法inflate(int)"
LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View error = layoutInflater.inflate(R.layout.error_internet_connection);
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
bI有以下java代码:
Intent intent = getIntent();
CO2 = intent.getIntExtra("CO2", 0);
TextView textCo2 = (TextView)findViewById(R.id.textRoadView1);
textCo2.setText(String.valueOf("CO2 emissions: "+CO2+"g"));
Run Code Online (Sandbox Code Playgroud)
和XML文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/textRoadView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".RoadDetails" >
<TextView
android:id="@+id/textRoadView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="38dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
因此,当我尝试在"textCo2"中设置一些文本时,我得到了这个奇怪的异常"Android widget relativelayout无法转换为android小部件textview." 我尝试删除"R.java"文件并清理项目,但问题仍在继续.我认为错误在我的代码中的某处,但我可以找到它.你能救我吗?
我是MVVM和Dagger的新手,我正在尝试在我的应用程序中使用Dagger 2和Butterknife实施MVVM。不幸的是,我得到以下错误:
error: @Modules cannot be scoped. Did you mean to scope a method instead?
Run Code Online (Sandbox Code Playgroud)
当我尝试使我的“ ViewModelModule”单例时出现此错误。这是我的课:
@Singleton
@Module
public abstract class ViewModelModule { ... }
Run Code Online (Sandbox Code Playgroud)
我在“ ApplicationModule”中引用“ ViewModelModule”,如下所示:
@Singleton
@Module(includes = ViewModelModule.class)
public class ApplicationModule { ... }
Run Code Online (Sandbox Code Playgroud)
如果我删除“ Singleton”注解,一切正常。但是我想念什么?我究竟做错了什么?
android ×9
android-mvvm ×1
coordinates ×1
dagger-2 ×1
formatting ×1
google-maps ×1
gps ×1
java ×1
layout ×1
mvvm ×1
passwords ×1
save ×1
textview ×1
translation ×1