我是android开发的新手,我的应用程序在调用特定活动时会崩溃。(“governanaceactivity”是活动的名称)当我从MainActivity调用治理活动时,我的应用程序会崩溃,其他菜单工作得很好,唯一的问题是这个活动。
package com.iridh.collegeapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private static long back_pressed;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Button more1=(Button)findViewById(R.id.btn_more);
more1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent= new Intent(MainActivity.this,GovernanceActivity.class);
startActivity(intent);
}
});
Button more2=(Button)findViewById(R.id.btn_more2);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, 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);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
Intent showIntent = new Intent();
if (id == R.id.nav_home) {
// Handle the camera action
} else if (id == R.id.nav_governance) {
> //problem getting here
showIntent = new Intent(MainActivity.this, GovernanceActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_Campus) {
showIntent = new Intent(MainActivity.this, CampusActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_department) {
showIntent = new Intent(MainActivity.this, DepartmentsActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_admission) {
showIntent = new Intent(MainActivity.this, AdmissionActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_facilities) {
showIntent = new Intent(MainActivity.this, FacilitiesActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_gallery) {
showIntent = new Intent(MainActivity.this, GalleryActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_placement) {
showIntent = new Intent(MainActivity.this, PlacementActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
} else if (id == R.id.nav_contact) {
showIntent = new Intent(MainActivity.this, ContactActivity.class);
startActivity(showIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
这是GovernanceActivity
package com.iridh.collegeapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class GovernanceActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_governance);
}
}
**所有其他活动都很好,只有这个活动有问题
这是我的宣言**
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iridh.collegeapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".GovernanceActivity"
android:parentActivityName=".MainActivity" />
<activity android:name=".CampusActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".DepartmentsActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".AdmissionActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".FacilitiesActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".GalleryActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".DownloadActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".PlacementActivity"
android:parentActivityName=".MainActivity"/>
<activity android:name=".ContactActivity"
android:parentActivityName=".MainActivity">
</activity>
</application>
</manifest>
Blockquote 05-21 03:09:53.747 182 3-1823/com.iridh.collegeApp d/AndroidRuntime:正在关闭VM 05-21 03:09:53.752 182 3-1823/com.iridh.collegeApp e/AndroidRuntime:致命异常:主进程:com.iridh.collegeApp,PID:1823 java.lang.runtimeException:无法启动活动ComponentInfo{com.iridh.collegeApp/com.iridh.collegeApp.governanceActivity}:ityThread.performLaunchActivity(ActivityThread.java:3194)在Android.app.activityThread.handlelaunchActivity(ActivityThread.java:3302)在Android.app.activityThread.-Wrap12(未知源码:0)在Android.app.activityThread.$h.handleMessage(ActivityThread.java:1891)在Android.os.handler.dispatchMessage(handler.java:108)在Android.os.handler.looper.loop ke(本机方法)位于com.android.internal.os.zygote$在com.android.internal.os.zygoteinit.main(zygoteinit.java:921)处运行(zygote.java:245),原因是:android.view.filf Impl.java:1371)在Android.content.res.resourcesimpl.loadcomplexcolorfromname(resourcesimpl.java:1190)在Android.content.res.resourcesimpl.loadcolorstatelist(resourcesimpl.java:1271)在Android.content.res.resources.loadcolorstatelist(resources.java:118)在Android.content.res.hwresources.loadcolorstatelist(resources.java:289)在va:1291)在Android.widget.textView。(textview.java:872)在Android.support.v7.widget.appCompattextView。(AppCompattextView.java:76)在Android.support.v7.widget.appCompattextView。(AppCompattextView.java:76)在Android.support.v7.widget.appCompattView.(cappCompattView.java:72)在delegateimplv9.java:1035)在Android.support.v7.app.appcompatdelegateimplv9.oncreateView(appcompatdelegateimplv9.java:1092)在Android.view.layoutinflater.createViewfromtag(layoutinflater.java:783)在Android.view.layoutinflater.java:741)在Android.view.layoutinflater.createViewfromtag(layoutinflater.java:741)在.java:877)在Android.view.layoutinflater.rflatechildren(layoutinflater。java:835)在Android.view.layoutinflater.rflate(layoutinflater.java:877)在Android.view.layoutinflater.rflatechildren(layoutinflater.java:835)在Android.view.layoutinflater.java:877)在Android.view.layoutinflater.rflatechildren(layoutinflater.java:835)在Android.view.layoutinflater.rflatechildren(Android.support.v7.app.appcompatdelegateimplv9.setContentView(appcompatdelegateimplv9.java:287)在Android.support.v7.app.app.compatactivity.setContentView(appcompatactivity.java:139)在com.iridh.collegeapp.governanceactivity.oncreate(governanceactivity.java:11)在Android.app.activity.performCreate(activity.java:7372)在.app.ActivityThread.HandleLaunchActivity(ActivityThread.java:3302)在Android.app.activityThread.-Wrap12(未知来源:0)在Android.app.activityThread.$H.HandleMessage(ActivityThread.java:1891)在Android.os.handler.dispatchMessage(handler.java:1891)在Android.os.handler.dispatchMessage(handler.java:108)在Android.app.activityThread.main(activityThread.java:166)在在com.android.internal.os.zygoteinit.main(zygoteinit.java:921)
发生了什么,我无法调试它,提前感谢。
此My GovernanceActivity附加布局
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.LinearLayoutCompat
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:id="@+id/governance_lyt"
android:background="@drawable/ic_menu_header_background">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="50dp"
android:elevation="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp">
<RelativeLayout
android:id="@+id/title_lyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF941020">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:textColor="#FFFFFF"
android:text="GOVERNANACE"
android:textSize="25dp"
android:textStyle="bold"
app:fontFamily="@font/android"
android:layout_alignParentLeft="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" "
android:textSize="15dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:paddingTop="20dp"
android:background="@android:color/darker_gray">
</View>
<android.support.v7.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
android:elevation="12dp"
android:shape="ring"
android:innerRadius="0dp"
android:layout_gravity="center"
android:thicknessRatio="1.9"
android:layout_centerHorizontal="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_president" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Shree Shankarprasad Agnihotri"
android:textSize="22dp"
android:textStyle="bold"
android:textColor="#263238"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="President"
android:textSize="17dp"
android:textStyle="bold"
android:textColor="#666666"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" "
android:textSize="15dp" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:elevation="100dp">
<RelativeLayout
android:id="@+id/title_lyt3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00e676">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="Message"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="bold"
app:fontFamily="@font/android"
android:layout_alignParentLeft="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="349dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="@string/president"
android:textSize="17dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:paddingTop="20dp"
android:background="@android:color/darker_gray">
</View>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" "/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" "/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:paddingTop="20dp"
android:background="@android:color/darker_gray">
</View>
<android.support.v7.widget.CardView
android:layout_width="100dp"
android:layout_height="100dp"
android:elevation="12dp"
android:shape="ring"
android:innerRadius="0dp"
android:layout_gravity="center"
android:thicknessRatio="1.9"
android:layout_centerHorizontal="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_secretary" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Sachin S. Agnihotri"
android:textSize="22dp"
android:textStyle="bold"
android:textColor="#263238"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Secretary"
android:textSize="17dp"
android:textStyle="bold"
android:textColor="#666666"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" "
android:textSize="15dp" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:elevation="100dp"
>
<RelativeLayout
android:id="@+id/title_lyt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background=" #00e676">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="Message"
android:textSize="20dp"
android:textColor="@drawable/black"
android:textStyle="bold"
app:fontFamily="@font/android"
android:layout_alignParentLeft="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="349dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="@string/secretary"
android:textSize="17dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:paddingTop="20dp"
android:background="@android:color/darker_gray">
</View>
</android.support.v7.widget.LinearLayoutCompat>
</ScrollView>
您必须将文件black.jpg
重命名为black.XML
,假设它是XML资源(如形状或选择器),或者将其重命名为black.png
,假设它是图像。
那是你的错误:
Exception:二进制XML文件第288行导致类TextView膨胀错误:Android.content.res.resources$NotFoundException:drawable resource ID#0x7f08005c.XML扩展名中的文件res/drawable/black.jpg导致类TextView膨胀错误
以下是您的错误:
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:text="Message"
android:textSize="20dp"
android:textColor="@drawable/black" <-- ERROR HERE
android:textStyle="bold"
app:fontFamily="@font/android"
android:layout_alignParentLeft="true" />
您正在textcolor
中设置drawable
,并且应该是color
资源。可以是@color/black
(black应该在colors.xml中定义为
,也可以是文字(Android:textcolor=“#000000”
)。
我有一个程序,它接收UDP包,从包中解析一些数据,并保存到一个数据库中。它通过Grails使用Hibernate和Spring(GORM独立)。 它在一台服务器上工作正常,启动速度很快(每个数据包20-30毫秒-除了JIT启动时的第一个数据包-),一段时间后稳定在50-60毫秒。 然而,在更新、更强大的服务器中,它启动速度很快,但逐渐变慢(每个数据包达到200ms甚至300ms,负载始终相同)。然
我已经用VS 2017创建了一个Android应用(Xamarin)导航抽屉应用。我在网上搜索了一个如何在应用程序中添加一个新活动的例子,该应用程序使用了已经创建的导航抽屉,但一直没有成功。有关于如何添加活动的想法吗? 谢谢保罗。
我正在使用Firebase来保存我的数据。我试图在活动中分离Firebase方法和我的方法。例如,我已经创建了一个名为"Firebase method odsHelper"的类,在那里我想编写所有的Firebase方法。例如,"getAllUser"方法应返回列表中的所有用户。我唯一的问题是它不起作用。 我不知道我做错了什么,所以如果你们能帮我。 碎片 FirebaseMethodHelper类
我有一个Spring启动,Hibernate使用java应用程序。我部署它在一个jetty webserver与多个实例.如果我有太多(大于10)很多实例我得到 许多连接(10x实例)显示为空闲 ps: 实例的Hikari跟踪日志: 设置 没有记录任何有趣的事情。我认为这看起来很有趣-连接不可用 有什么办法可以调试这个吗?我也在java 7上,所以hikari 2.4.7
前面提到多进程的并行可以提高并发度,那么进程是越多越好?一般遇到这种问题都回答不是,事实上,很多大型项目都不会同时开太多进程。 下面以支持100K并发量的Nginx服务器为例。 举个例子: Nginx Nginx是一个高性能、高并发的Web服务器,也就是说它可以同时处理超过10万个HTTP请求,而它建议的启动的进程数不要超过CPU个数,为什么呢? 我们首先要知道Nginx是Master-worke