我创建了一个简单的ImageView,并尝试点击时启动一个活动,但当我在模拟器中单击它时,该应用只是崩溃并给我(等待或在这里关闭应用程序提示) 是我:android应用关闭时没有错误,当点击imageview时
XML:
<?xml version="1.0" encoding="utf-8"?>
<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:fillViewport="true"
android:orientation="vertical">
<ImageView
android:id="@+id/about"
android:layout_width="match_parent"
android:layout_height="450dp"
android:background="@color/colorPrimaryDark"
android:src="@drawable/twoth" />
</LinearLayout>
这里是我的Java代码
public class MainUi extends AppCompatActivity {
//Variables Declaration.
private Button btn1, btn2, btn3, btn4;
private ImageView img;
//Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_ui);
//Variables Initialization and OnClick Method
img = (ImageView) findViewById(R.id.about);
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
//Start another activity
Intent myIntent = new Intent(MainUi.this, Query.class);
startActivity(myIntent);
}
});
}
}
是您的清单中定义的查询?你的logcat显示任何错误? –
你的图像的分辨率@ drawable/twoth?如果它太大,而您没有调整它的大小以更正可绘制的文件夹,则可能是内存问题。 –
“等待或关闭”的事情让我认为查询活动中有一些东西在主线程上做了很多工作。您可以发布任何可能需要很长时间才能处理并处于查询活动状态的代码吗? –