第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

如何將 PLEASE SELECT 錯(cuò)誤添加到 JSON Spinner

如何將 PLEASE SELECT 錯(cuò)誤添加到 JSON Spinner

我有一個(gè)應(yīng)用程序,您可以在其中將圖像上傳到我公司的服務(wù)器我有 2 個(gè)微調(diào)器填充了 json 數(shù)據(jù),微調(diào)器中的選定項(xiàng)目被傳遞給上傳 url 的 uri.builder,我已經(jīng)看到很多關(guān)于設(shè)置請選擇微調(diào)器上的選項(xiàng)但是我的微調(diào)器的請選擇選項(xiàng)作為項(xiàng)目編碼到我的 JSON 數(shù)據(jù)中?,F(xiàn)在我想要的是,如果選擇了 please select item 以提示用戶在微調(diào)器中選擇一個(gè)項(xiàng)目,應(yīng)用程序?qū)⒔o出一個(gè)錯(cuò)誤總而言之,我的微調(diào)器中填充了 json 數(shù)據(jù),json 數(shù)據(jù)中的第一項(xiàng)是“請選擇”,如果選擇了“請選擇”選項(xiàng),我希望顯示一條錯(cuò)誤消息。   public class SecondActivity extends AppCompatActivity implements    View.OnClickListener {private final int PICK_IMAGE=12345;private final int REQUEST_CAMERA=6352;private static final int REQUEST_CAMERA_ACCESS_PERMISSION=5674;private Bitmap bitmap;private ImageView imageView; String myURL; Spinner spinner; Spinner spinner2; String URL; String URL2; ArrayList<String> CategoryName; ArrayList<String> ClientName; String Item; String Item2; String email; String clientId; String pwd;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);     setContentView(R.layout.activity_second);     imageView=findViewById(R.id.imageView);     Button fromCamera=findViewById(R.id.fromCamera);     Button fromGallery=findViewById(R.id.fromGallery);     Button upload=findViewById(R.id.upload);     CategoryName=new ArrayList<>();     ClientName=new ArrayList<>();     spinner=findViewById(R.id.spinner);     spinner2=findViewById(R.id.spinner2);     email = getSharedPreferences("MyPrefs", MODE_PRIVATE).getString("name", "");     clientId= getSharedPreferences("MyPrefs", MODE_PRIVATE).getString("id", "");     pwd= getSharedPreferences("MyPrefs", MODE_PRIVATE).getString("password", "");    CheckBox chk =findViewById(R.id.chk1);    if (chk.isChecked()) {         Uri.Builder builder=new Uri.Builder();         builder.scheme("https")
查看完整描述

2 回答

?
冉冉說

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊

將以下行添加到微調(diào)器方法的頂部onItemSelected。


  if(i==0){

    ///Here you need to show the error msg for the first item selected

    Log.v("ERROR","Please select an item callded");


    //return is used the break the flow of the app so the code below does not run in this case

    return;


    }


查看完整回答
反對 回復(fù) 2023-06-14
?
DIEA

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超2個(gè)贊

在第一個(gè)位置添加您的項(xiàng)目。在 Spinner 上添加一個(gè) Item Selected Check Listner 并添加一個(gè)檢查是否選擇的值是第一個(gè)。如果先顯示消息


spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override

    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {

        // your code here

        if(position==0)

            Toast.makeText(getContext,"Please select a value",Toast.LENGTH_LONG).show()

    }


    @Override

    public void onNothingSelected(AdapterView<?> parentView) {

        // your code here

    }


});


查看完整回答
反對 回復(fù) 2023-06-14
  • 2 回答
  • 0 關(guān)注
  • 154 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號