无法在Android Studio中显示“心情”

时间:2019-05-25 11:21:05

标签: android android-spinner

我正在开发乳制品应用程序。当我单击乳制品时,“情绪”无法显示。但是其他的,例如主观的也可以。我正在使用微调器来表达“心情”。而且我不知道如何解决“ moodEt.putExtra(moo);”?

使用“ moodEt.setText(moo)”显示心情

预期:在更新页面中显示“心情” 错误:“心情”没有显示。

使用“ moodEt.setText(moo)”显示心情

    //passing Update Activity's context to database alass
    dbUpdate = new SqliteDatabase(this);
    SQLiteDatabase sqliteDatabase = dbUpdate.getWritableDatabase();

    moodEt = (Spinner)findViewById(R.id.moodEditTextIdUpdate);
    String[] MOODLIST = getResources().getStringArray(R.array.MoodList);

    ArrayAdapter<String> spinAdp = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,MOODLIST);
    spinAdp.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    moodEt.setAdapter(spinAdp);


    subjectEt = findViewById(R.id.subjectEditTextIdUpdate);
    descriptionEt = findViewById(R.id.descriptionEditTextIdUpdate);

    cancelBt = findViewById(R.id.cacelButtonIdUpdate);
    updateBt = findViewById(R.id.saveButtonIdUpdate);
    shareBtOnUpdate = findViewById(R.id.shareButtonIdUpdate);

    Intent intent = getIntent();
    Bundle bundle = getIntent().getExtras();
    String moo = intent.getStringExtra("mood");
    //String moo = String.valueOf(moodEt.getSelectedItem());
    String sub = intent.getStringExtra("subject");
    String des = intent.getStringExtra("description");
    final String id = intent.getStringExtra("listId");
    //TextView moodEt = findViewById(R.id.moodEditTextIdUpdate);
    // moodEt.putExtra(moo);
    //moodEt.setPrompt(moo);

    moodEt.setPrompt(moo);
    subjectEt.setText(sub);
    descriptionEt.setText(des);

    //for sharing data to social media
    shareBtOnUpdate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent shareIntent =   new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            String moo = String.valueOf(moodEt.getSelectedItem());
            //String moo = moodEt.getText().toString();
            shareIntent.putExtra(Intent.EXTRA_SUBJECT,moo);
            String sub = subjectEt.getText().toString();
            shareIntent.putExtra(Intent.EXTRA_SUBJECT,sub);
            String des = descriptionEt.getText().toString();
            shareIntent.putExtra(Intent.EXTRA_TEXT,des);
            startActivity(Intent.createChooser(shareIntent, "Share via"));
        }
    });

    cancelBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    //for updating database data
    updateBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Date date = new Date();
            String d = (String) DateFormat.format("dd/MM/yyyy  hh:mm:ss",date);

            if(dbUpdate.update(id,String.valueOf(moodEt.getSelectedItem()),subjectEt.getText().toString(),descriptionEt.getText().toString(),d)==true){
                Toast.makeText(getApplicationContext(),"Data updated",Toast.LENGTH_SHORT).show();
                backToMain();
            }
        }
 });
}

//this method to clearing top activity and starting new activity
    public void backToMain()
     {
    Intent intent = new Intent(UpdateActivity.this,MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    finish();
    startActivity(intent);
     }
    }

预期:在更新页面中显示“心情” 错误:“心情”没有显示。

0 个答案:

没有答案