java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0

qq_30685735 2015-09-02 12:52:27
求大神帮助呀


package com.example.tv7;

import java.util.ArrayList;
import java.util.List;

import impl.ngb.toolkit.channelscan.ChannelScanNITSuccessEventImpl;

import org.davic.mpeg.ResourceException;
import org.ngb.broadcast.dvb.si.SIService;
import org.ngb.broadcast.dvb.tuning.DvbcTuningParameters;
import org.ngb.toolkit.channelscan.ChannelScanEngine;
import org.ngb.toolkit.channelscan.ChannelScanEvent;
import org.ngb.toolkit.channelscan.ChannelScanFailureEvent;
import org.ngb.toolkit.channelscan.ChannelScanFinishEvent;
import org.ngb.toolkit.channelscan.ChannelScanListener;
import org.ngb.toolkit.channelscan.ChannelScanNITSuccessEvent;
import org.ngb.toolkit.channelscan.ChannelScanSuccessEvent;








import com.enrich.evmtv.evmtvManager;
import com.example.tv7.R.string;

import android.os.Bundle;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;

public class MainActivity extends Activity {

ChannelScanEngine engine;

private TextView t;
private TextView t1;
private TextView t2;
private TextView t3;
private TextView t4;

private static List<Sservice> mlist=new ArrayList<Sservice>();




@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
evmtvManager.init(getApplicationContext());

//查找控件并设置点击事件
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {


@Override
public void onClick(View arg0) {

change1();
t = (TextView) findViewById(R.id.textview1);
String s = mlist.get(0).getId()+""+mlist.get(0).getName()+mlist.get(0).getType();
System.out.println(s);
t.setText(s);

t1 = (TextView) findViewById(R.id.textview2);
String s1=mlist.get(1).getId()+""+mlist.get(1).getName()+mlist.get(1).getType();
t1.setText(s1);


t2 = (TextView) findViewById(R.id.textview3);
String s2=mlist.get(2).getId()+""+mlist.get(2).getName()+mlist.get(2).getType();
t2.setText(s2);

t3 = (TextView) findViewById(R.id.textview4);
String s3=mlist.get(3).getId()+""+mlist.get(3).getName()+mlist.get(3).getType();
t3.setText(s3);

}

});
}
class Sservice{

int id;
String name;
int type;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}

}
private void change1() {
// TODO Auto-generated method stub
try {
if(engine == null)
engine = ChannelScanEngine.createInstance();
DvbcTuningParameters[] params = new DvbcTuningParameters[1];
params[0] = new DvbcTuningParameters();
params[0].setFrequency(323000);
params[0].setSymbolRate(6875000);
params[0].setModulation(DvbcTuningParameters.DVB_C_MOD_QAM64);
engine.addChannelScanListener(new ChannelScanListener() {

private List<Sservice> list;

@Override
public void processEvent(ChannelScanEvent event) {
// TODO Auto-generated method stub
if(event instanceof ChannelScanNITSuccessEvent){
ChannelScanNITSuccessEventImpl nitEvent = (ChannelScanNITSuccessEventImpl)event ;

}else if(event instanceof ChannelScanSuccessEvent ){
ChannelScanSuccessEvent successEvent = (ChannelScanSuccessEvent)event;
SIService[] siServiceS = successEvent.getResult();

List<Sservice> list=new ArrayList<Sservice>();
for(SIService service:siServiceS){
Sservice s = new Sservice();

int id=service.getServiceID();
String name= service.getServiceName();
int type = service.getServiceType();

s.setId(id);
s.setName(name);
s.setType(type);
list.add(s);
System.out.println(s+"");
for(int i=0;i<list.size();i++){
mlist.add(list.get(i));

}
}

}else if(event instanceof ChannelScanFinishEvent){

}else if(event instanceof ChannelScanFailureEvent){

}
}
});
engine.startScan(ChannelScanEngine.CHANNELSCAN_TYPE_MANUAL, params);
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}
...全文
200 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
maiyikai 2015-09-02
  • 打赏
  • 举报
回复
哪个地方?出错??能否给个行数?

23,406

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧