- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Android Studio 创建一个应用程序。我使用了默认的登录 Activity 模板,然后创建了一个新的单独的注册 Activity 。它因 NullPointerException
崩溃。我尝试将这两个 Activity 链接在一起,如下所示:
LoginActivity.java:
public class LoginActivity extends Activity implements LoaderCallbacks<Cursor> {
/**
* A dummy authentication store containing known user names and passwords.
* TODO: remove after connecting to a real authentication system.
*/
private static final String[] DUMMY_CREDENTIALS = new String[]{
"foo@example.com:hello", "bar@example.com:world"
};
/**
* Keep track of the login task to ensure we can cancel it if requested.
*/
private UserLoginTask mAuthTask = null;
// UI references.
private AutoCompleteTextView mEmailView;
private EditText mPasswordView;
private View mProgressView;
private View mLoginFormView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login2);
Button mSignUpTextView;
mSignUpTextView = (Button)findViewById(R.id.SignUpButton);
mSignUpTextView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, SignUpActivity.class);
startActivity(intent);
}
});
// Set up the login form.
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
populateAutoComplete();
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) {
attemptLogin();
return true;
}
return false;
}
});
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
}
和SignUpActivity.java:
public class SignUpActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_sign_up, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
activity_login2.xml 文件是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
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="com.redux.kumardivyarajat.attendance.LoginActivity"
android:weightSum="1"
android:id="@+id/activity_login2">
<!-- Login progress -->
<ProgressBar android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="174dp">
<LinearLayout android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1"
android:touchscreenBlocksFocus="false">
<AutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:layout_weight="10.63">
<requestFocus/>
</AutoCompleteTextView>
<EditText android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
<Button android:id="@+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_sign_in_short"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SignupText"
android:text="@string/sign_up_from_login"
android:textColor="#ffff0500" />
<Button
style="?android:textAppearanceSmall"
android:id="@+id/SignUpButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Sign Up"
android:textStyle="bold"
android:layout_gravity="center_horizontal" />
</LinearLayout>
在登录 Activity 中添加新的注册按钮之前,应用程序运行良好,但现在立即崩溃。
logcat 显示 NullPointerException
:
04-03 19:29:44.486 4648-4648/com.redux.kumardivyarajat.attendance E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.redux.kumardivyarajat.attendance, PID: 4648
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.redux.kumardivyarajat.attendance/com.redux.kumardivyarajat.attendance.LoginActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2190)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2239)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5047)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.redux.kumardivyarajat.attendance.LoginActivity.onCreate(LoginActivity.java:69)
at android.app.Activity.performCreate(Activity.java:5249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2154)
我了解 NullPointerException
的常见原因,但我无法确定它在我的代码中是如何发生的。我该如何解决这个问题?
最佳答案
事实证明,由于我的应用的某些元素不适用于 API 级别 14 及以下版本,因此单独的 activity_login2.xml 和 activity_login2.xml(v14) 文件已已自动生成。
出现 NullPointerException
是因为第二个 activity_login2.xml(v14) 文件中未定义新的注册按钮。我已经更新了该文件,现在应用程序运行良好。
关于java - 更改代码后诊断 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29426831/
当我在一台机器上启动我的应用程序时,它立即退出说它已经“停止工作”。在事件日志中,我看到 MissingMethodException 是原因。没有显示异常对话框,并且在事件日志详细信息中我看不到任何
我正在从 Windows Phone 8 模拟器调用 Azure 移动服务。有时我会收到没有 InnerException 属性的 MobileServiceInvalidOperationExcep
我正在创建一个 Web 客户端,用于使用 ACS Calling SDK 加入 Teams session 。我在加载诊断 API 时遇到问题。 Microsoft 提供了此页面: https://l
知道为什么我的应用程序被杀死吗?我是该节点的唯一用户。 我的历史记录服务器也没有显示任何内容。我如何进一步追踪并了解是谁杀死了它,以及为什么以及如何修复它? ubuntu@anmol-vm1-new:
我正在创建一个 Web 客户端,用于使用 ACS Calling SDK 加入 Teams session 。我在加载诊断 API 时遇到问题。 Microsoft 提供了此页面: https://l
我正在寻找一种从 Windows Azure 中的性能计数器获取原始数据的方法 使用诊断 API。 到目前为止,我注意到我可以从已知的计数器中配置一个计数器 并设置该计数器的采样率。 诊断配置中配置的
我在将 WebRole(WCF 服务)部署到 Azure 时遇到问题。我的 WebRole 持续显示忙碌状态至少 30 分钟,直到我中止它。我通过 Visual Studio 2010 进行部署。我正
Clang has several kinds of diagnostics ,其中三种主要是错误、警告和注释。 注释通常伴随着某些警告和错误,例如重复定义: error: conflicting t
调试由于 Win32 生产过程中的死锁而导致的明显挂起的步骤和技术是什么。我听说 WinDbg 可用于此目的,但您能否提供有关如何实现此目的的明确提示? 最佳答案 此 post应该让您开始使用各种选项
我有一个在 Azure 上运行的应用程序,它会记录(实际上是跟踪)到 Azure 诊断存储。我正在寻找一个可以用来分析这些日志的好工具。 我知道可以使用 Visual Studio 中的服务器资源管理
我在当前项目中使用 Bazel 经历了很长的“干净构建”时间。 我们推荐的诊断步骤是什么? 最佳答案 尝试使用 --profile 分析您的构建 语法为 bazel build --profile f
我在解释 gcc (4.8.2) 警告和错误时遇到问题。更准确地说,很难分辨一个问题在哪里结束,另一个问题从哪里开始。我只能通过控制台访问构建机器,因此不能选择使用 IDE。 我真的需要能够快速区分个
我想为我的 azure 云服务启用 azure 诊断,但我有点困惑。 我读了这篇文章:https://learn.microsoft.com/en-us/azure/cloud-services/cl
我想我这里有个卷曲的地方...我有一个WinForms应用程序,当它作为x64进程运行时,它每小时大约会定期崩溃。我怀疑这是由于堆栈损坏引起的,并且想知道是否有人看到过类似的问题,或者是否有诊断和检测
我正在研究 Azure Web 角色的性能改进,并想知道在发布/部署到生产站点时是否应保留诊断。 This article说要禁用它,但其中一条评论说您会丢失关键数据。 最佳答案 您绝对应该启用它。一
我的解决方案中有多个 Web 和辅助角色,但我还有一个在 Azure 托管 VM 上运行的非 Azure 应用程序。该应用程序连接到 Azure 存储以执行各种操作,例如读取和写入 blob 和队列,
我仍在努力理清思路 Azure Service Fabric Stateful Actors 。因此,我的(当前)问题最好放入这样的示例中: 我有一个帮助台系统,其中每张票证都是一个有状态的参与者。参
CUDA 到处都有大量文档和指南,但我找不到任何形式的说明来指导如何诊断编译但收到神秘、模糊错误消息(例如“未指定启动”)的内核“这些 block /网格结构有意义吗?”等等 我可以以某种方式拦截cu
我没有找到太多解决 azure 事件网格中事件丢失场景的方法。 因此我提出与以下场景相关的问题: 我们的代码将事件发布到域。 事件将传送到订阅中配置的网络 Hook 。 这在一段时间内有效。 消费者(
这个问题有点宽泛,但我觉得没有一个地方可以帮助系统地诊断 Elasticsearch 问题。广泛的类别可能是: 客户 查询错误 查询结果不正确 无法解释的行为 服务器 设置问题 性能问题 严重错误 无
我是一名优秀的程序员,十分优秀!