我是一名意大利学生,使用最新版本的Android Studio和Android API 26(Android Oreo)开发Android应用程序。
申请很简单:
1.主要活动“MySchoolSyllabus”:显示学校科目列表,由放置在“res”项目文件夹中的图像表示。
2.第二项活动,“Materia”(意思是“主题”):一旦用户点击主题图像,就需要打开此活动,显示另一个图像列表,以与上一个活动相同的方式表示该主题的主题。
3.最终活动,“Argomento”(意思是“主题”):一旦用户点击主题图片,就需要打开此活动,使用WebView显示主题课程(我将在共享Google上存储所有课程)开车帐户)。
我使用ItemAdapter创建主题和主题列表。 现在,我不是Android编程方面的专家,所以我没有对所有内容进行编码...... 但是当我点击“MySchoolSyllabus”活动中的图像时,第二个活动“Materia”没有打开。
这就是我现在写的。
我该如何解决?
// MySchoolSyllabus.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.ArrayList;
public class MySchoolSyllabus extends AppCompatActivity implements Item_Adapter.ItemListener {
Item_Adapter item_adapter;
ArrayList<Integer> pass = new ArrayList<>();
ArrayList<String> nome = new ArrayList<>();
ListView list;
void CaricaDati () {
nome.clear();
nome.add("Italiano");
nome.add("Matematica");
nome.add("Arte");
nome.add("Biologia");
nome.add("Chimica");
nome.add("Elettronica");
nome.add("Filosofia");
nome.add("Fisica");
nome.add("Geografia");
nome.add("Informatica");
nome.add("Inglese");
nome.add("Storia");
pass.clear();
pass.add(R.drawable.italiano_banner);
pass.add(R.drawable.matematica_banner);
pass.add(R.drawable.arte_banner);
pass.add(R.drawable.biologia_banner);
pass.add(R.drawable.chimica_banner);
pass.add(R.drawable.elettronica_banner);
pass.add(R.drawable.filosofia_banner);
pass.add(R.drawable.fisica_banner);
pass.add(R.drawable.geografia_banner);
pass.add(R.drawable.informatica_banner);
pass.add(R.drawable.inglese_banner);
pass.add(R.drawable.storia_banner);
item_adapter.notifyDataSetChanged();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_school_syllabus);
item_adapter = new Item_Adapter(this, R.layout.row, pass);
item_adapter.setItemListener(MySchoolSyllabus.this);
list = findViewById(R.id.lista);
list.setAdapter(item_adapter);
CaricaDati();
}
@Override
public void startNewIntent(int position) {
Intent materia = new Intent(MySchoolSyllabus.this, Materia.class);
materia.putExtra("materia", nome.get(position));
startActivityForResult(materia, 10);
}
}
// Materia.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.ArrayList;
public class Materia extends AppCompatActivity implements Item_Adapter.ItemListener {
Item_Adapter item_adapter;
ArrayList<Integer> pass = new ArrayList<>();
ArrayList<String> nome = new ArrayList<>();
ListView list;
String arg, materia;
//Here I didn't code topics yet in the switch. I'll do it the future. This is not important now.
void CaricaDati (String m) {
nome.clear();
switch (m) {
case "Italiano":
nome.clear();
//
pass.clear();
//
break;
case "Matematica":
nome.clear();
//
pass.clear();
//
break;
case "Arte":
nome.clear();
//
pass.clear();
//
break;
case "Biologia":
nome.clear();
//
pass.clear();
//
break;
case "Chimica":
nome.clear();
//
pass.clear();
//
break;
case "Elettronica":
nome.clear();
//
pass.clear();
//
break;
case "Filosofia":
nome.clear();
//
pass.clear();
//
break;
case "Fisica":
nome.clear();
//
pass.clear();
//
break;
case "Geografia":
nome.clear();
//
pass.clear();
//
break;
case "Informatica":
nome.clear();
//
pass.clear();
//
break;
case "Inglese":
nome.clear();
//
pass.clear();
//
break;
case "Storia":
nome.clear();
//
pass.clear();
//
break;
}
item_adapter.notifyDataSetChanged();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_materia);
materia = getIntent().getStringExtra("materia");
item_adapter = new Item_Adapter(this, R.layout.row, pass);
item_adapter.setItemListener(Materia.this);
list = findViewById(R.id.lista);
list.setAdapter(item_adapter);
CaricaDati(materia);
}
@Override
public void startNewIntent(int position) {
arg = nome.get(position);
String dispensa = materia + "_" + arg;
Intent argomento = new Intent(Materia.this, Argomento.class);
argomento.putExtra("dispensa", nome.get(position));
startActivityForResult(argomento, 10);
}
}
// Item_Adapter.java
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.List;
public class Item_Adapter extends ArrayAdapter<Integer> {
public interface ItemListener {
void startNewIntent(int position);
}
ItemListener listener = null;
public void setItemListener(ItemListener item) {
listener = item;
}
public Item_Adapter(@NonNull Context context, int resource, @NonNull List<Integer> objects) {
super(context, resource, objects);
}
@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.row, parent, false);
}
LinearLayout linear = convertView.findViewById(R.id.materia);
linear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(listener != null) listener.startNewIntent(position);
}
});
ImageView imageView = convertView.findViewById(R.id.imageView);
imageView.setBackgroundResource(getItem(position));
return convertView;
}
}
// activity_my_school_syllabus.xml(与materia XML布局相同)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="wrap_content"
tools:context="com.example.fabio.myschoolsyllabus.MySchoolSyllabus">
<ListView
android:id="@+id/lista"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
// row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/materia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:layout_width="match_parent"
android:id="@+id/imageView"
android:layout_height="120dp"/>
</LinearLayout>
//的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fabio.myschoolsyllabus">
<uses-permission android:name="android.permission.INTERNET" />
<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=".MySchoolSyllabus">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Materia"></activity>
<activity android:name=".Argomento"></activity>
</application>
</manifest>
答案 0 :(得分:0)
update a set a.yourcolumn=a.newcolumnvalue
from t3 a join (
SELECT db.tab1.id as id
FROM db.tab1 JOIN db.tab2
ON db.tab1.caseid = db.tab2.padid
WHERE db.tab1.caseid=702)b
on a.id=b.id
〜
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/materia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:id="@+id/imgButton"
android:layout_width="match_parent"
android:layout_height="120dp"/>
</LinearLayout>
答案 1 :(得分:0)
请将所有活动声明为AndroidManifest文件。