我有一个问题。当我运行我的应用程序时,我想用按钮打开新活动。这适用于一个活动,但另一个活动(主菜单中的两个按钮,其中一个不工作)只关闭应用程序。以下是该活动的代码和错误的logcat。 Logcat说glutilsparamsize存在问题
我的问题是它不想打开活动。我的按钮Opis和Izlaz工作,他们打开活动opis和izlaz按钮退出,但按钮pronadi说" com.example.shromid。停止"并关闭应用程序。我想打开活动项目。
LOGCAT错误
01-31 09:49:47.351 4576-4596/com.example.shromid E/eglCodecCommon:
glUtilsParamSize: unknow param 0x00008cdf
01-31 09:49:47.352 4576-4596/com.example.shromid E/eglCodecCommon:
glUtilsParamSize: unknow param 0x00008cdf
01-31 09:49:47.360 4576-4596/com.example.shromid E/eglCodecCommon:
glUtilsParamSize: unknow param 0x00008824
01-31 09:49:47.360 4576-4596/com.example.shromid E/eglCodecCommon:
glUtilsParamSize: unknow param 0x00008824
我要打开的活动
package com.example.shromid;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class Pronadi extends Activity {
Spinner kboja;
Spinner ktekstura;
Spinner koblik;
ArrayAdapter<String> adapter;
ArrayAdapter<String> adapter1;
ArrayAdapter<String> adapter2;
DatabaseHelper db;
List<String>gljive=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pronadi);
kboja = (Spinner) findViewById(R.id.kboja);
ktekstura = (Spinner) findViewById(R.id.ktekstura);
koblik = (Spinner) findViewById(R.id.koblik);
db = new DatabaseHelper(Pronadi.this);
prepareData();
prepareData1();
prepareData2();
kboja.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(), "" + parent.getItemAtPosition(position).toString(), Toast.LENGTH_SHORT);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
koblik.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(),""+parent.getItemAtPosition(position).toString(),Toast.LENGTH_SHORT);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
ktekstura.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(),""+parent.getItemAtPosition(position).toString(),Toast.LENGTH_SHORT);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
public void prepareData() {
gljive=db.getKlobuk_Boja();
adapter=new ArrayAdapter<String>(Pronadi.this,android.R.layout.simple_spinner_dropdown_item,android.R.id.text1,gljive);
kboja.setAdapter(adapter);
}
public void prepareData1() {
gljive=db.getKlobuk_Oblik();
adapter1=new ArrayAdapter<String>(Pronadi.this,android.R.layout.simple_spinner_dropdown_item,android.R.id.text1,gljive);
koblik.setAdapter(adapter1);
}
public void prepareData2(){
gljive=db.getKlobuk_Tekstura();
adapter2=new ArrayAdapter<String>(Pronadi.this,android.R.layout.simple_spinner_dropdown_item,android.R.id.text1,gljive);
ktekstura.setAdapter(adapter2);
}
}
带按钮以打开活动的活动
package com.example.shromid;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
izlaz();
otvoriopis();
otvoripronadi();
}
public Button btnopis;
public void otvoriopis(){
btnopis=(Button)findViewById(R.id.btnopis);
btnopis.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent otvoriopis= new Intent(MainActivity.this,Opis.class);
startActivity(otvoriopis);
}
});
}
public Button btnpronadi;
public void otvoripronadi(){
btnpronadi=(Button)findViewById(R.id.btnpronadi);
btnpronadi.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent otvoripronadi= new Intent(MainActivity.this,Pronadi.class);
startActivity(otvoripronadi);
}
});
}
public Button btnizlaz;
public void izlaz(){
btnizlaz=(Button)findViewById(R.id.btnizlaz);
btnizlaz.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
finish();
System.exit(0);
}
});
}
}
&#13;
android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shromid">
<application
android:allowBackup="true"
android:icon="@mipmap/app_ikona"
android:roundIcon="@mipmap/app_icon_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashScreen"
android:label="ShromID"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
<activity android:name=".Opis" />
<activity android:name=".Pronadi"></activity>
</application>
</manifest>
&#13;
主要活动xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:background="@drawable/pozadina2"
android:orientation="vertical"
tools:context="com.example.shromid.MainActivity">
<!-- Gumbovi u glavnom meniju -->
<Button
android:id="@+id/btnpronadi"
android:layout_width="183dp"
android:layout_height="56dp"
android:layout_marginBottom="11dp"
android:background="@drawable/gumbpronadi"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/btnopis"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
<Button
android:id="@+id/btnopis"
android:layout_width="183dp"
android:layout_height="56dp"
android:layout_marginBottom="11dp"
android:background="@drawable/gumbopis"
app:layout_constraintBottom_toTopOf="@+id/btnizlaz"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnpronadi" />
<Button
android:id="@+id/btnizlaz"
android:layout_width="183dp"
android:layout_height="56dp"
android:layout_marginBottom="106dp"
android:background="@drawable/gumbizlaz"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnopis" />
<!-- Kraj gumbova u glavnom meniju -->
<!-- Logo u glavnom meniju -->
<ImageView
android:id="@+id/imageView3"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginEnd="30dp"
android:layout_marginStart="30dp"
android:layout_marginTop="16dp"
android:src="@drawable/gljiveprobna"
app:layout_constraintBottom_toTopOf="@+id/btnpronadi"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" android:contentDescription="@string/todo" />
</android.support.constraint.ConstraintLayout>
&#13;