呵呵,谢谢大家的回复,我在这方面很新,你们都帮了我很多。Thigns 现在已修复,应用程序也在按我的意愿运行。我想我无法结束这个问题,但它对我来说很重要^^
我有一个可展开的列表视图。
下面的全部内容是我的 MainActivity.java
其中有 2 个错误,都在 } 上。
我确信它们放置正确。尝试更新软件等,但由于某种原因我无法让错误消失。
它是最后一个 } 和之前的一个 return false }
代码从这里开始:
package com.example.sk17;
import com.example.adapterr.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.ExpandableListView.OnGroupCollapseListener;
import android.widget.ExpandableListView.OnGroupExpandListener;
import android.widget.Toast;
public class MainActivity extends Activity {
ExpandableListAdapter listAdapter;
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get the listview
expListView = (ExpandableListView) findViewById(R.id.lvExp);
// preparing list data
prepareListData();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
// setting list adapter
expListView.setAdapter(listAdapter);
}
private OnChildClickListener myListItemClicked = new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Toast.makeText(MainActivity.this, "Clicked On Child"+childPosition,
Toast.LENGTH_SHORT).show();
// Go to child #0 specific class.
Intent child0Intent = new Intent(this, activity0.class);
startActivity(Intent);
}
return false;
}
/*
* Preparing the list data
*/
private void prepareListData() {
listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<String>>();
// Adding child data
listDataHeader.add("1 SAFETY PRECAUTIONS");
listDataHeader.add("2 MACHINE FAMILIARIZATION");
listDataHeader.add("3 MACHINE OPERATION");
listDataHeader.add("4 MAINTENANCE");
listDataHeader.add("5 TRANSPORTATION");
listDataHeader.add("6 SPECIFICATIONS");
listDataHeader.add("7 OPTIONAL EQUIPMENT");
listDataHeader.add("8 TROUBLESHOOTING");
listDataHeader.add("9 SPECIAL PROCEDURES");
// Adding child data
List<String> SAFETYPRECAUTIONS = new ArrayList<String>();
SAFETYPRECAUTIONS.add("1.1 GENERAL SAFETY INFORMATION");
SAFETYPRECAUTIONS.add("1.2 SAFETY PRECAUTIONS");
SAFETYPRECAUTIONS.add("1.3 PRE-START SAFETY");
SAFETYPRECAUTIONS.add("1.4 SAFETY DURING OPERATION");
SAFETYPRECAUTIONS.add("1.5 INSPECTION & MAINTENANCE SAFETY");
SAFETYPRECAUTIONS.add("1.6 BATTERY SAFETY");
SAFETYPRECAUTIONS.add("1.7 WARNING LABELS & DECALS");
SAFETYPRECAUTIONS.add("1.8 PROHIBITED MACHINE OPERATION");
SAFETYPRECAUTIONS.add("1.9 END OF WORK SHIFT SAFETY");
SAFETYPRECAUTIONS.add("1.10 TRANSPORTATION");
SAFETYPRECAUTIONS.add("1.11 TOWING THE MACHINE");
List<String> MACHINEFAMILIARIZATION = new ArrayList<String>();
MACHINEFAMILIARIZATION.add("2.1 FAMILIARIZATION");
MACHINEFAMILIARIZATION.add("2.2 GENERAL MACHINE NOMENCLATURE");
MACHINEFAMILIARIZATION.add("2.3 OPERATOR CAB NOMENCLATURE");
MACHINEFAMILIARIZATION.add("2.4 COMPONENT & CONTROLS NOMENCLATURE");
List<String> MACHINEOPERATION = new ArrayList<String>();
MACHINEOPERATION.add("3.1 BASIC MACHINE OPERATION");
List<String> MAINTENANCE = new ArrayList<String>();
MAINTENANCE.add("4.1 GENERAL INFORMATION");
MAINTENANCE.add("4.2 GENERAL SAFETY & PRECAUTIONS");
MAINTENANCE.add("4.3 LUBRICANT, FUEL & COOLANT SPECIFICATIONS");
MAINTENANCE.add("4.4 MAINTENANCE PARTS");
MAINTENANCE.add("4.5 ACCESSORY TOOLS");
MAINTENANCE.add("4.6 TORQUE SPECIFICATIONS FOR BOLTS & NUTS");
MAINTENANCE.add("4.7 TORQUE SPECIFICATIONS FOR JOINTS & HYDRAULIC HOSES");
MAINTENANCE.add("4.8 INSTALLING HYDRAULIC HOSE AND PIPE JOINT FITTINGS");
MAINTENANCE.add("4.9 RELEASING INTERNAL PRESSURE OF HYDRAULIC SYSTEM");
MAINTENANCE.add("4.10 BLEEDING AIR IN FUEL SYSTEM");
MAINTENANCE.add("4.11 REPLACING RUBBER CRAWLER BELT");
MAINTENANCE.add("4.12 INSPECTION & MAINTENANCE CHART");
MAINTENANCE.add("4.13 OTHER MAINTENANCE - PERFORMED WHEN REQUIRED");
MAINTENANCE.add("4.14 PRE-START (EVERY 8 HOURS) INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.15 50-HOUR (WEEKLY) INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.16 250-HOUR (3-MONTH) INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.17 500-HOUR (6-MONTH) INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.18 1000-HOUR (12-MONTH) INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.19 2000-HOUR INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.20 5000-HOUR INSPECTION AND MAINTENANCE");
MAINTENANCE.add("4.21 INSPECTION / MAINTENANCE CHECK LIST");
List<String> TRANSPORTATION = new ArrayList<String>();
TRANSPORTATION.add("5.1 PREPARING FOR MACHINE TRANSPORTATION.");
TRANSPORTATION.add("5.2 LIFTING THE MACHINE");
TRANSPORTATION.add("5.3 WEIGHT AND DIMENSION SPECIFICATIONS");
List<String> SPECIFICATIONS = new ArrayList<String>();
SPECIFICATIONS.add("6.1 GENERAL SPECIFICATIONS");
List<String> OPTIONALEQUIPMENT = new ArrayList<String>();
OPTIONALEQUIPMENT.add("7.1 OPERATION OF HYDRAULIC BREAKER AND NIBBLER");
OPTIONALEQUIPMENT.add("7.2 SAFETY PRECAUTIONS");
OPTIONALEQUIPMENT.add("7.3 PERIODIC INSPECTION AND MAINTENANCE INTERVAL");
List<String> TROUBLESHOOTING = new ArrayList<String>();
TROUBLESHOOTING.add("8.1 GENERAL TROUBLESHOOTING");
List<String> SPECIALPROCEDURES = new ArrayList<String>();
SPECIALPROCEDURES.add("9.1 MOVING A DISABLED MACHINE.");
SPECIALPROCEDURES.add("9.2 RELEASING LOCK ON TRAVEL MOTOR");
listDataChild.put(listDataHeader.get(0), SAFETYPRECAUTIONS); // Header, Child data
listDataChild.put(listDataHeader.get(1), MACHINEFAMILIARIZATION);
listDataChild.put(listDataHeader.get(2), MACHINEOPERATION);
listDataChild.put(listDataHeader.get(3), MAINTENANCE);
listDataChild.put(listDataHeader.get(4), TRANSPORTATION);
listDataChild.put(listDataHeader.get(5), SPECIFICATIONS);
listDataChild.put(listDataHeader.get(6), OPTIONALEQUIPMENT);
listDataChild.put(listDataHeader.get(7), TROUBLESHOOTING);
listDataChild.put(listDataHeader.get(8), SPECIALPROCEDURES);
}
}