这是Dialog类,我将新人添加到静态列表
public class DialogInput extends Dialog{
public static List<Person> person = new LinkedList<Person>();
Text txtName;
@Override
protected Control createPartControl(Composite parent){
...
txtName = new Text(parent, SWT.NONE);
}
@Override
protected void okPressed(){
Person p = new Person();
p.setName(txtName.getText());
person.add(p);
}
}
//另一个CLASS在另一个文件中。
public class MyView extends ViewPart{
public void createPartControl(Composite parent){
// HOW TO GET LIST ?
}
}
答案 0 :(得分:1)
public class MyView extends ViewPart{
public void createPartControl(Composite parent){
// HOW TO GET LIST ?
List<Person> personList = DialogInput.person;
}
}
答案 1 :(得分:0)
试试这个:
public class MyView extends ViewPart{
public void createPartControl(Composite parent){
List<String> pList = DialogInput.person;
}
}