单击列表视图中的项目时的StringIndexOutOfBoundException

时间:2014-12-19 04:23:11

标签: java android eclipse

我有一个列表视图,其中包含从数据库中检索到的数据,如果我点击某个项目,则会假设导航到另一个活动。

然而,当我点击某个项目

时,我会收到此错误
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.anistat/com.example.anistat.MemberExercise}:
java.lang.StringIndexOutOfBoundsException: length=0; index=9

这是onItemClick函数列表

    private boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager 
          = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
Boolean net;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_member_exercise);
    setTitle("AniStat");
    net=isNetworkAvailable();

    if(net){

    Button next = (Button) findViewById(R.id.membernextex);

    btnDownloadPDF = (Button) findViewById(R.id.memberexsavepdf);
    btnDownloadPDF.setVisibility(View.VISIBLE);
    // getting data
    Intent i = getIntent();
    eid = i.getStringExtra("ID");
    cha = i.getStringExtra("chapter");
    lev = i.getStringExtra("level");
    user = i.getStringExtra("user");
    id = i.getStringExtra("eid");// 1 2 3
    id = id.substring(9);

    if (!id.equals("")){

    if (id.equals("1")) {
        nextid = "2";
    }
    if (id.equals("2")) {
        nextid = "3";

    }
    if (id.equals("3")) {
        next.setVisibility(View.GONE);

    }}

问题是什么?

0 个答案:

没有答案