According to the existing code is copied, before the title on the top displays the currently selected options, but do not know how the they don't have a
CodePudding user response:
Will you look complete code posted the activity
CodePudding user response:
Have you ever used setTitle this way? Your activity references to see them get rid of the title
CodePudding user response:
refer to the second floor Ande Wang reply: you have used this method setTitle? Your activity references to see them get rid of the title used Settitle, what do you think the theme of reference CodePudding user response:
reference 1st floor zhang106209 response: to your post and see the complete code of all the activity package com. Example. Myapplication51; The import android. App. The Activity; The import android. OS. Bundle; The import android. View. The view; The import android. Widget. AdapterView; The import android. Widget. ArrayAdapter; The import android. Widget. The Button; The import android. Widget. ListView. The import android. Widget. TextView; Public class MainActivity extends the Activity { Private TextView txtResult; Private String m=""; Private TextView tm; Private ListView lstPrefer; Private Button btnDo; String [] Fruits=new String [] {5 yuan "apple", "orange 3 yuan", "banana 2 yuan"}; int count; @ Override Public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); The setContentView (R.l ayout. Activity_main); //resources category in the file interface components BtnDo=(Button) the findViewById (R.i db tnDo); TxtResult=(TextView) the findViewById (R.i which xtResult); Tm=(TextView) the findViewById (R.i which m); LstPrefer=(ListView) the findViewById (R.i d.l stPrefer); //to multi-select template ArrayAdapter ArrayAdapter AdapterBalls=new ArrayAdapter (this, Android. R.l ayout simple_list_item_multiple_choice, Fruits); LstPrefer. SetChoiceMode (ListView. CHOICE_MODE_MULTIPLE);//set the multiselect //set the ListView data LstPrefer. SetAdapter (adapterBalls); Count=adapterBalls. GetCount ();//select project total //set button component Click event listener for btnDoListener BtnDo. SetOnClickListener (btnDoListener); //set lstPrefer component ItemClick event listener for lstPreferListener LstPrefer. SetOnItemClickListener (lstPreferListener); } //define the onClick () method Private Button. An OnClickListener btnDoListener=new Button. An OnClickListener () { Public void onClick (View v) { String selAll=""; For (int p=0; P & lt; count; P++) { If (lstPrefer. IsItemChecked (p)) SelAll +=Fruits [p] + ""; } If (selAll. Equals (5 yuan "apple")) { M=5 yuan "; } else if (selAll equals (" orange 3 yuan ")) { M="a total of 3 yuan"; } else if (selAll equals (" banana 2 yuan ")) { M="$2"; } else if (selAll equals (5 yuan "apple" + "orange 3 yuan")) { M="8 yuan"; } else if (selAll equals (5 yuan "apple" + "banana 2 yuan")) { M="7 yuan"; } else if (selAll equals (" banana 2 yuan "+" orange 3 yuan ")) { M=5 yuan "; } else if (selAll equals (5 yuan "apple" + "orange 3 yuan" + "banana 2 yuan")) { M="10 yuan"; } TxtResult. SetText (" selected fruit: "+ selAll); Tm. SetText (" total amount "+ m); } }; //definition onItemClick method Private ListView. OnItemClickListener lstPreferListener= New ListView. OnItemClickListener () { @ Override Public void onItemClick (AdapterView<?> The parent View v, Int position, long id) { If (lstPrefer isItemChecked (position)) {//check String sel=parent. GetItemAtPosition (position). The toString (); SetTitle (" the choice: "+ sel); } else { SetTitle (" the choice: "); } } }; CodePudding user response:
Quote: refer to the third floor weixin_44900828 response: In the androidmanifest.xml android: theme="@ style/AppTheme" CodePudding user response:
<style name="AppTheme" parent "=" Theme. AppCompat. Light. DarkActionBar "& gt; <style name="transparent" parent "=" Theme. AppCompat. Light. NoActionBar "& gt; This is not the title of the custom style style CodePudding user response:
f Ande reference Wang reply: & lt; Style name="AppTheme" parent "=" Theme. AppCompat. Light. DarkActionBar "& gt; <style name="transparent" parent "=" Theme. AppCompat. Light. NoActionBar "& gt; This is not the title of the custom style style I the inside have no the ah CodePudding user response:
Your AndroidManifest. XML and style. The XML file to CodePudding user response:
You change MainActivity inherited Activity to AppCompatActivity CodePudding user response:
Now is not inherited AppCompatActivity, inherit the Activity all don't know is a few years ago