Java 导致设备运行缓慢的应用程序
我最近听说了Butterknife api,所以我决定制作一个小益智应用程序来熟悉它。但是,当我尝试运行代码时,会出现一个通知,告诉我该应用程序导致我的手机运行缓慢,并且它会消耗我设备的内存,而不会给出错误堆栈。有人能告诉我这有什么问题吗 MainActivity.javaJava 导致设备运行缓慢的应用程序,java,android,xml,butterknife,Java,Android,Xml,Butterknife,我最近听说了Butterknife api,所以我决定制作一个小益智应用程序来熟悉它。但是,当我尝试运行代码时,会出现一个通知,告诉我该应用程序导致我的手机运行缓慢,并且它会消耗我设备的内存,而不会给出错误堆栈。有人能告诉我这有什么问题吗 MainActivity.java public class MainActivity extends AppCompatActivity { Context context = getApplicationContext(); CharSequence te
public class MainActivity extends AppCompatActivity {
Context context = getApplicationContext();
CharSequence text = "It's ALIVE!!";
int duration = Toast.LENGTH_SHORT;
@Bind(R.id.button_main_one) Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
}
@OnClick(R.id.button_main_one)
public void button_clicked()
{
Toast toast = Toast.makeText(context,text, duration);
}
@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_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);
}}
活动\u main.xml
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<Button
android:id="@+id/button_main_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Here"/>
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.jibbgh.eightslider"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'InvalidPackage'
}