1
나머지는 here을 따라갔습니다. 그러나, 그건 내 코딩 문제가있는 것 같습니다. 처음에는이 활동에 처음 도착했을 때 첫 번째 항목을 목록에 표시해야하지만 비어있는 것은 아닙니다. 운 좋게도 목록은 스피너를 클릭하면 선택됩니다. 그리고 또한, 내가 선택한 후, 축배는 나타나지 않았다.스피너에서 선택한 항목 가져 오기
package android.wps;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
public class locationFinder extends Activity {
WifiPositioningServices wifiPositioningServices = new WifiPositioningServices();
ArrayList<Profile> profileList = new ArrayList<Profile>();
ArrayList<String> profileNames = new ArrayList<String>();
ArrayList<String> mapNames = new ArrayList<String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationfinder);
String[] temp = wifiPositioningServices.GetAllProfileData();
final Spinner profiles = (Spinner)findViewById(R.id.profileList);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,
profileNames);
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
profiles.setAdapter(spinnerArrayAdapter);
profiles.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long arg3) {
// TODO Auto-generated method stub
String test = parent.getItemAtPosition(pos).toString();
Toast toast = Toast.makeText(parent.getContext(), test, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
//store all profile data into a ArrayList of Profile objects
for(int i=0; i<temp.length; i++){
String[] result = temp[i].split(",");
Profile profile = new Profile();
profile.setProfileName(result[0]);
profile.setOwner(result[1]);
profile.setMap(result[2]);
profile.setVisible(result[3]);
boolean visible = Boolean.valueOf(result[3]);
if(visible){
//if visible is true, then add profile name and mac filters into arraylist
profileNames.add(result[0]);
for(int j=4; j<result.length; j++){
profile.setMacFiltersList(result[j]);
}
}
profileList.add(profile);
}
}
} : 다음
09-07 06:30:06.470: WARN/InputManagerService(50): Window already focused, ignoring focus gain of: [email protected]
이 활동에 대한 코드입니다 :이 난 내 선택을하게이 후에는 DDMS에서 팝업으로의 원인인지 확실하지 않다
locationfiner.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/txtPofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile:"
android:textStyle="bold"
android:layout_x="10px"
android:layout_y="12px"
>
</TextView>
<Spinner
android:id="@+id/profileList"
android:layout_width="245px"
android:layout_height="36px"
android:layout_x="70px"
android:layout_y="12px"
>
</Spinner>
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_x="0px"
android:layout_y="32px"
/>
</AbsoluteLayout>
에 루프
를 참조하고있는이 코드를 게시 할 수 있습니다. –
게시 한 코드 부분이 괜찮은 것 같습니다. 그래서 오류가 어딘가에 있어야합니다 ... –
안녕하세요 @Nishant, 나는 코딩과 함께 내 질문을 업데이 트했습니다. – user918197