2013-03-29 2 views
-3
public class CodeMainActicity extends Activity 
{ 
private ExpandListAdapter ExpAdapter; 
private ArrayList<ExpandListGroup> ExpListItems; 
private ExpandableListView ExpandList; 
public String[] groups = null; 
public String[][] headers = null; 
DisplayMetrics metrics; 
int width; 

public int GetDipsFromPixel(float paramFloat) 
{ 
    return (int)(0.5F + paramFloat * getResources().getDisplayMetrics().density); 
} 

public ArrayList<ExpandListGroup> SetStandardGroups() 
{ 
ArrayList<ExpandListGroup> localArrayList1 = new ArrayList<ExpandListGroup>(); 
int i = 0; 
if (i >=groups.length){ 
    return localArrayList1; 
} 
ExpandListGroup localExpandListGroup = new ExpandListGroup(); 
localExpandListGroup.setName(groups[i]); 
ArrayList<ExpandListChild> localArrayList2 = new ArrayList<ExpandListChild>(); 
for (int j = 0; ; j++) 
{ 
    if (j > 11){ 


    while (headers[i][j] == null) 
    { 
    localExpandListGroup.setItems(localArrayList2); 
    localArrayList1.add(localExpandListGroup); 
    i++; 
    break; 
    } 
    } 

    ExpandListChild localExpandListChild = new ExpandListChild(); 
    localExpandListChild.setName(headers[i][j]); 
    localExpandListChild.setTag(null); 
    localArrayList2.add(localExpandListChild); 
} 
} 

    public void onCreate(Bundle paramBundle) 
{ 
this.groups = new String[11]; 
this.headers = ((String[][])Array.newInstance(String.class, new int[] { 14, 10 })); 
this.groups[0] = "Data Types"; 
this.groups[1] = "Date Time"; 
this.groups[2] = "Regular Expressions"; 
this.groups[3] = "Class"; 
this.groups[4] = "Collections"; 
this.groups[5] = "Generics"; 
this.groups[6] = "Reflection"; 
this.groups[7] = "Security"; 
this.groups[8] = "Design Patterns"; 
this.groups[9] = "Thread"; 
this.groups[10] = "File Stream"; 
this.headers[0][0] = "Boxing and Unboxing"; 
this.headers[0][1] = "Complex Type"; 
this.headers[0][2] = "Enum"; 
this.headers[0][3] = "Tuple type"; 
this.headers[0][4] = "Hex to Int"; 
this.headers[0][5] = "Nullable Integer"; 
this.headers[0][6] = "Custom ToString()"; 
this.headers[0][7] = "Checked() and Unchecked()"; 
this.headers[0][8] = "Overflow"; 
this.headers[0][9] = "Char methods"; 
this.headers[1][0] = "Get between Days"; 
this.headers[1][1] = "Add one week to current date"; 
this.headers[1][2] = "DateTime Compare"; 
this.headers[2][0] = "Email Validation"; 
this.headers[2][1] = "URL validation"; 
this.headers[2][2] = "Zipcode validation"; 
this.headers[3][0] = "Access modifiers"; 
this.headers[3][1] = "Inheritance"; 
this.headers[3][2] = "Interface"; 
this.headers[3][3] = "Method Overloading"; 
this.headers[3][4] = "Overriding"; 
this.headers[3][5] = "Abstract class"; 
this.headers[4][0] = "Array List"; 
this.headers[4][1] = "Hash Table"; 
this.headers[4][2] = "Dictionary"; 
this.headers[5][0] = "Simple Generic hierarchy"; 
this.headers[5][1] = "Generic IEnumerable"; 
this.headers[5][2] = "Generic Collection class"; 
this.headers[6][0] = "AppDomain Setup"; 
this.headers[6][1] = "Type.GetMethods"; 
this.headers[6][2] = "Assembly Version Information"; 
this.headers[7][0] = "MD5 encode"; 
this.headers[7][1] = "File Checksum"; 
this.headers[7][2] = "Password Encryption"; 
this.headers[8][0] = "Facade Pattern"; 
this.headers[8][1] = "Factory Pattern"; 
this.headers[8][2] = "Observer Pattern"; 
this.headers[8][3] = "Singleton Pattern"; 
this.headers[8][4] = "Adapter Pattern"; 
this.headers[9][0] = "Creating Thread"; 
this.headers[9][1] = "Asynchronous Calls"; 
this.headers[9][2] = "Mutex"; 
this.headers[10][0] = "Display File contents"; 
this.headers[10][1] = "Write to a file"; 
this.headers[10][2] = "Append to File"; 
super.onCreate(paramBundle); 
requestWindowFeature(1); 
setContentView(R.layout.codemainscreen); 
Button localButton = (Button)findViewById(R.id.btnhome); 
this.ExpandList = ((ExpandableListView)findViewById(R.id.ExpList)); 
ExpListItems = SetStandardGroups(); 
this.ExpAdapter = new ExpandListAdapter(this, this.ExpListItems); 
this.metrics = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(this.metrics); 
this.width = this.metrics.widthPixels; 
this.ExpandList.setIndicatorBounds(this.width - GetDipsFromPixel(50.0F), this.width - GetDipsFromPixel(10.0F)); 
this.ExpandList.setAdapter(this.ExpAdapter); 
+0

어떤 라인이 해당 라인을 찾을 수 있도록 logcat을 게시하시기 바랍니다. –

+0

LogCat please? 그렇지 않으면 코드에 오류가있을 수 있습니다. –

+1

http://stackoverflow.com/questions/how-to-ask – JimmyB

답변

1

당신은에서에게 어떤이가있는 동안 충돌 후 즉이 루프

for (int j = 0; ; j++) 

에는 조건이 없습니다.

for (int j = 0; /* add condition here */ ; j++) { 
    if (j > 11){ 
    while (headers[i][j] == null) ... // or here ArrayIndexOutOfBoundsException 

건배!

+1

OP는 질문을하는 것을 귀찮게하지 않았지만 답변을 제공하는 데 시간이 걸렸습니다. :) – JimmyB

+1

그런데 : ** (j> 11) ** {while (headers [i] ** [j] ** ...이 경우에는 가능하지 않습니다. – JimmyB

관련 문제