我有2栏时,多选择列表视图 [英] i got 2 toolbar when multi select in listview

查看:214
本文介绍了我有2栏时,多选择列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有一个问题,我的应用程序的短信,当我的$一个触点P $ PSS它显示新的工具栏,但我不知道是谁删除其他工具栏:/

如果你能帮助我谢谢你..

下面是我的主要活动:

 包com.ducha.messavtext;进口android.annotation.TargetApi;
进口android.content.ContentUris;
进口android.content.ContentValues​​;
进口android.content.Context;
进口android.content.Intent;
进口android.database.Cursor;
进口android.net.Uri;
进口android.os.Build;
进口android.os.Bundle;
进口android.provider.BaseColumns;
进口android.provider.ContactsContract;
进口android.provider.Telephony;
进口android.support.v7.app.AppCompatActivity;
进口android.support.v7.widget.Toolbar;
进口android.util.Log;
进口android.util.SparseBooleanArray;
进口android.view.ActionMode;
进口android.view.Menu;
进口android.view.MenuItem;
进口android.view.View;
进口android.widget.AbsListView;
进口android.widget.AdapterView;
进口android.widget.ListView;进口com.ducha.training3.R;进口的java.util.ArrayList;@TargetApi(Build.VERSION_ codeS.KITKAT)
公共类MainActivity扩展AppCompatActivity实现BaseColumns {    私人光标指针;
    私人光标cursorPhone;
    私人光标cursorContact;    私人最终乌里uriSms = Telephony.Sms.CONTENT_URI;
    私人最终乌里uriPhone = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    私人最终乌里URI = Uri.parse(内容://短信/收件箱);
    私人字符串的身体;
    私人字符串NUMERO;
    私人字符串ID;
    私人字符串接触;    私人最终的String [] = selectionSms新的String [] {Telephony.Sms._ID,Telephony.Sms.BODY,Telephony.Sms.THREAD_ID,Telephony.Sms.ADDRESS,Telephony.Sms.DATE,Telephony.Sms.READ,};
    私人最终的String [] = selectionPhone新的String [] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,ContactsContract.CommonDataKinds.Phone.NUMBER,};
    私人最终的String [] = selectionContact新的String [] {ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME,};    公共静态的ArrayList< CreateContactAdapter> listContact =新的ArrayList<>();;
    公共静态布尔runMain;
    公共静态ContactAdapter适配器;
    公共静态的byte [] myPhoto;    私人的ArrayList<串GT; IDLIST =新的ArrayList<>();;
    私人上下文CTX =这一点;
    私人诠释读取;
    私人INT messageUnread = 0;
    私人的ListView LV;
    私人的ArrayList<串GT; diffNumber;
    私人字节[]的照片;
    私人工具栏工具栏;    @覆盖
    保护无效onResume(){
        super.onResume();
        runMain = TRUE;
    }    @覆盖
    保护无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);        clearIfNotEmpty();
        isTheDefaultApp();
        findId();
        getInfoMain();
        getMyContactPicture();
        ConfigToolbar();
        lv.setAdapter(适配器);
        lv.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);        lv.setMultiChoiceModeListener(新AbsListView.MultiChoiceModeListener(){
            @覆盖
            公共无效onItemCheckedStateChanged(ActionMode模式,INT位置,长的ID,布尔检查){
                最终诠释将selectedItem = lv.getCheckedItemCount();
                mode.setTitle(将selectedItem +项选择);
            }            @覆盖
            公共布尔onCreateActionMode(ActionMode模式,菜单菜单){                。mode.getMenuInflater()膨胀(R.menu.select_menu,菜单);
                返回true;
            }            @覆盖
            在prepareActionMode公共布尔(ActionMode模式,菜单菜单){
                返回false;
            }            @覆盖
            公共布尔onActionItemClicked(ActionMode为arg0,菜单项项){
                开关(item.getItemId()){
                    案例R.id.remove_item:
                        SparseBooleanArray选择= adapter.getSelectedIds();                        的for(int i =(select.size() - 1); I> = 0;我 - ){
                            如果(select.valueAt(ⅰ)){
                                CreateContactAdapter接触=(CreateContactAdapter)adapter.getItem(select.keyAt(I));
                                adapter.remove(接触);
                            }
                        }
                        arg0.finish();
                        返回true;                    默认:
                        返回false;
                }
            }            @覆盖
            公共无效onDestroyActionMode(ActionMode模式){
                adapter.removeSelection();
            }
        });
        lv.setOnItemClickListener(新AdapterView.OnItemClickListener(){
            @覆盖
            公共无效onItemClick(适配器视图<>母公司,观景,INT位置,长的id){
                意向意图=新意图(MainActivity.this,PrintMessage.class);
                字符串persoId = listContact.get(位置).ID;
                字符串NUMERO = listContact.get(位置).numero;
                弦接触= listContact.get(位置)名为.contact;
                绳体= listContact.get(位置)。体;
                字节[] = BMP listContact.get(位置).photo;
                intent.putExtra(ID,persoId);
                intent.putExtra(NUMERO,NUMERO);
                intent.putExtra(联系,联系方式);
                intent.putExtra(照片,BMP);
                markMessageRead(CTX,NUMERO,体);
                startActivity(意向);
            }
        });
    }    私人无效clearIfNotEmpty(){
        如果(!listContact.isEmpty())
            listContact.clear();
    }    私人无效getMyContactPicture(){
        乌里uriContact = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,Uri.en code(0659641613));
        cursorContact = this.getContentResolver()查询(uriContact,selectionContact,NULL,NULL,NULL);
        cursorContact.moveToFirst();
        长idContact = cursorContact.getLong(0);
        myPhoto = openPhoto(idContact);
    }    @TargetApi(Build.VERSION_ codeS.KITKAT)
    私人无效isTheDefaultApp(){
        最后弦乐的packageName = MainActivity.this.getPackageName();
        如果(!Telephony.Sms.getDefaultSmsPackage(MainActivity.this).equals(的packageName)){
            意向意图=新意图(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
            intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,的packageName);
            startActivity(意向);
        }
    }    私人无效findId(){
        工具栏=(栏)findViewById(R.id.my_toolbar);
        LV =(ListView控件)findViewById(R.id.ListView01);
    }    @TargetApi(Build.VERSION_ codeS.KITKAT)
    公共无效getInfoMain(){
        光标= this.getContentResolver()查询(uriSms,selectionSms,NULL,NULL,日期DESC)。
        如果(cursor.moveToFirst()){
            而(!cursor.isAfterLast()){
                ID = cursor.getString(2);
                如果(!(idList.contains(ID))){
                    体= cursor.getString(1);
                    NUMERO = cursor.getString(3);
                    读= cursor.getInt(5);
                    如果(阅读== 0)
                        messageUnread ++;
                    diffNumber = getDifferentNumber(NUMERO);
                    cursorPhone = this.getContentResolver()查询(uriPhone,selectionPhone,
                            ContactsContract.CommonDataKinds.Phone.NUMBER +='+ diffNumber.get(0)+'或+
                                    ContactsContract.CommonDataKinds.Phone.NUMBER +='+ diffNumber.get(1)+'或+
                                    ContactsContract.CommonDataKinds.Phone.NUMBER +='+ diffNumber.get(2)+'或+
                                    ContactsContract.CommonDataKinds.Phone.NUMBER +='+ diffNumber.get(3)+',NULL,NULL);
                    如果(cursorPhone.moveToFirst()){
                        触点= cursorPhone.getString(0);
                        乌里uriContact = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,Uri.en code(NUMERO));
                        cursorContact = this.getContentResolver()查询(uriContact,selectionContact,NULL,NULL,NULL);
                        cursorContact.moveToFirst();
                        长idContact = cursorContact.getLong(0);
                        照片= openPhoto(idContact);
                        如果(照片!= NULL)
                            listContact.add(新CreateContactAdapter(联系人,NUMERO,身体,身份证,照片,读取));
                        其他
                            listContact.add(新CreateContactAdapter(联系人,NUMERO,身体,ID,空,读));
                    }其他{                        listContact.add(新CreateContactAdapter(否,NUMERO,身体,标识,空,读));
                    }
                    idList.add(ID);
                }
                cursor.moveToNext();
            }
        }
        cursor.close();
        适配器=新ContactAdapter(listContact,这一点);
    }    私人无效ConfigToolbar(){
        setSupportActionBar(工具栏);
        如果(messageUnread大于0)
            。getSupportActionBar()的setTitle(消息(+ messageUnread +));
        其他
            getSupportActionBar()的setTitle(信息)。
    }    公众的byte [] openPhoto(长的ContactID){
        乌里contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,使用ContactID);
        乌里photoUri = Uri.withAppendedPath(contactUri,ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
        光标光标= getContentResolver()查询(photoUri,新的String [] {} ContactsContract.Contacts.Photo.PHOTO,NULL,NULL,NULL);
        如果(光标== NULL){
            返回null;
        }
        尝试{
            如果(cursor.moveToFirst()){
                字节[]数据= cursor.getBlob(0);
                如果(数据!= NULL){
                    返回的数据;
                }
            }
        } {最后
            cursor.close();
        }
        返回null;
    }    私人无效markMessageRead(上下文的背景下,串号,串体){        光标光标= context.getContentResolver()查询(URI,NULL,NULL,NULL,NULL);
        尝试{            而(cursor.moveToNext()){
                如果((cursor.getString(cursor.getColumnIndex(地址))等于(数字))及。及(cursor.getInt(cursor.getColumnIndex(读))== 0)){
                    如果(cursor.getString(cursor.getColumnIndex(身体))。startsWith(体)){
                        字符串SmsMessageId = cursor.getString(cursor.getColumnIndex(_ ID));
                        ContentValues​​值=新ContentValues​​();
                        values​​.put(读,真正的);
                        。context.getContentResolver()更新(Uri.parse(内容://短信/收件箱),价值观,_id =+ SmsMessageId,NULL);
                        返回;
                    }
                }
            }
        }赶上(例外五){
            Log.e(标记已读,读中的错误:+ e.toString());
        }
    }    公众的ArrayList<串GT; getDifferentNumber(串号){
        ArrayList的<串GT; NUM =新的ArrayList<>();
        如果(number.matches(^ [06 | 07] {2} [0-9] {8})){
            num.add(number.replaceAll($ 0){2}。);
            num.add(number.replaceAll(06,336));
            num.add(number.replaceAll($ 0).replaceAll(0,+33){2}。);
            num.add(数);
        }否则如果(number.matches([06 | 07] {2}([0-9] {2}){4})){
            num.add(number.replaceAll(,));
            num.add(number.replaceAll(0,+33));
            num.add(number.replaceAll(,).replaceAll(0,+33));
            num.add(数);
        }否则如果(number.matches(\\\\ + [3] {2} [0-9] {8}。)){
            num.add(number.replaceAll(\\\\ + 33,0));
            num.add(number.replaceAll(\\\\ + 33,0)的replaceAll($ 0)。{2}。);
            num.add(number.replaceAll(\\\\ + 33,0)的replaceAll($ 0).replaceAll(^ 0,+33)。{2}。);
            num.add(数);
        }否则如果(number.matches(\\\\ + 33 [6 | 7]([0-9] {2}){4})){
            num.add(number.replaceAll(,));
            num.add(number.replaceAll(,).replaceAll(\\\\ + 33,0));
            num.add(number.replaceAll(,).replaceAll(\\\\ + 33,0)的replaceAll($ 0)。{2}。);
            num.add(数);
        }其他{
            num.add(NUMERO);
            num.add(NUMERO);
            num.add(NUMERO);
            num.add(NUMERO);
        }
        返回NUM;
    }    公共布尔编辑(菜单项项){
        //动作
        返回true;
    }    公共布尔NewMessage作为(菜单项项){
        startActivity(新意图(这一点,NewMessage.class));
        返回true;
    }    @覆盖
    公共布尔onCreateOptionsMenu(菜单菜单){
        。getMenuInflater()膨胀(R.menu.main_menu,菜单);
        返回true;
    }    @覆盖
    公共布尔onOptionsItemSelected(菜单项项){
            开关(item.getItemId()){
                案例R.id.setting:
                    startActivity(新意图(这一点,Apparence.class));
            }
        返回true;
    }    @覆盖
    保护无效的onPause(){
        super.onPause();
        runMain = FALSE;
    }
}


解决方案

尝试添加以下到您的styles.xml:

 <样式名称=MyAppTheme父=Theme.AppCompat.Light.NoActionBar>    <项目名称=colorPrimary> @彩色/ my_primary_color< /项目>
    <项目名称=colorPrimaryDark> @彩色/ my_primary_dark_color< /项目>
    <项目名称=colorAccent> @彩色/ my_accent_color< /项目>
    <项目名称=windowActionModeOverlay>真< /项目>< /风格>

Hi everyone I got a problem with my app SMS, when I long press on a contact it show the new toolbar but I don't know who to remove the other toolbar :/

if you can help me thank you ..

Here is my Main activity :

package com.ducha.messavtext;

import android.annotation.TargetApi;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.provider.ContactsContract;
import android.provider.Telephony;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListView;

import com.ducha.training3.R;

import java.util.ArrayList;

@TargetApi(Build.VERSION_CODES.KITKAT)
public class MainActivity extends AppCompatActivity implements BaseColumns {

    private Cursor cursor;
    private Cursor cursorPhone;
    private Cursor cursorContact;

    private final Uri uriSms      = Telephony.Sms.CONTENT_URI;
    private final Uri uriPhone    = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
    private final Uri uri         = Uri.parse("content://sms/inbox");


    private String body;
    private String numero;
    private String id;
    private String contact;

    private final String[] selectionSms         = new String[]{Telephony.Sms._ID, Telephony.Sms.BODY, Telephony.Sms.THREAD_ID, Telephony.Sms.ADDRESS, Telephony.Sms.DATE, Telephony.Sms.READ,};
    private final String[] selectionPhone       = new String[]{ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER,};
    private final String[] selectionContact     = new String[]{ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME,};

    public static ArrayList<CreateContactAdapter>   listContact = new ArrayList<>();;
    public static boolean                           runMain;
    public static ContactAdapter                    adapter;
    public static byte[]                            myPhoto;

    private         ArrayList<String>   idList          = new ArrayList<>();;
    private         Context             ctx             = this;
    private         int                 read;
    private         int                 messageUnread   = 0;
    private         ListView            lv;
    private         ArrayList<String>   diffNumber;
    private         byte[]              photo;
    private         Toolbar             toolbar;

    @Override
    protected void onResume() {
        super.onResume();
        runMain = true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        clearIfNotEmpty();
        isTheDefaultApp();
        findId();
        getInfoMain();
        getMyContactPicture();
        ConfigToolbar();
        lv.setAdapter(adapter);
        lv.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);

        lv.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
            @Override
            public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
                final int selectedItem = lv.getCheckedItemCount();
                mode.setTitle(selectedItem + " Item selected");
            }

            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {

                mode.getMenuInflater().inflate(R.menu.select_menu, menu);
                return true;
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(ActionMode arg0, MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.remove_item:
                        SparseBooleanArray select = adapter.getSelectedIds();

                        for (int i = (select.size() - 1); i >= 0; i--) {
                            if (select.valueAt(i)) {
                                CreateContactAdapter contact = (CreateContactAdapter) adapter.getItem(select.keyAt(i));
                                adapter.remove(contact);
                            }
                        }
                        arg0.finish();
                        return true;

                    default:
                        return false;
                }
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
                adapter.removeSelection();
            }
        });
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent   = new Intent(MainActivity.this, PrintMessage.class);
                String persoId  = listContact.get(position).id;
                String numero   = listContact.get(position).numero;
                String contact  = listContact.get(position).contact;
                String body     = listContact.get(position).body;
                byte[] bmp      = listContact.get(position).photo;
                intent.putExtra("id", persoId);
                intent.putExtra("numero", numero);
                intent.putExtra("contact", contact);
                intent.putExtra("photo", bmp);
                markMessageRead(ctx, numero, body);
                startActivity(intent);
            }
        });
    }

    private void clearIfNotEmpty() {
        if (!listContact.isEmpty())
            listContact.clear();
    }

    private void getMyContactPicture() {
        Uri uriContact  = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode("0659641613"));
        cursorContact   = this.getContentResolver().query(uriContact, selectionContact, null, null, null);
        cursorContact.moveToFirst();
        long idContact = cursorContact.getLong(0);
        myPhoto = openPhoto(idContact);
    }

    @TargetApi(Build.VERSION_CODES.KITKAT)
    private void isTheDefaultApp() {
        final String packageName = MainActivity.this.getPackageName();
        if (!Telephony.Sms.getDefaultSmsPackage(MainActivity.this).equals(packageName)) {
            Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
            intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, packageName);
            startActivity(intent);
        }
    }

    private void findId() {
        toolbar = (Toolbar) findViewById(R.id.my_toolbar);
        lv = (ListView) findViewById(R.id.ListView01);
    }

    @TargetApi(Build.VERSION_CODES.KITKAT)
    public void getInfoMain() {
        cursor = this.getContentResolver().query(uriSms, selectionSms, null, null, "date DESC");
        if (cursor.moveToFirst()) {
            while (!cursor.isAfterLast()) {
                id = cursor.getString(2);
                if (!(idList.contains(id))) {
                    body    = cursor.getString(1);
                    numero  = cursor.getString(3);
                    read    = cursor.getInt(5);
                    if (read == 0)
                        messageUnread++;
                    diffNumber = getDifferentNumber(numero);
                    cursorPhone = this.getContentResolver().query(uriPhone, selectionPhone,
                            ContactsContract.CommonDataKinds.Phone.NUMBER + "='" + diffNumber.get(0) +"' OR " +
                                    ContactsContract.CommonDataKinds.Phone.NUMBER + "='" + diffNumber.get(1) + "' OR " +
                                    ContactsContract.CommonDataKinds.Phone.NUMBER + "='" + diffNumber.get(2) + "' OR " +
                                    ContactsContract.CommonDataKinds.Phone.NUMBER + "='" + diffNumber.get(3) + "'", null, null);
                    if (cursorPhone.moveToFirst()) {
                        contact         = cursorPhone.getString(0);
                        Uri uriContact  = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(numero));
                        cursorContact   = this.getContentResolver().query(uriContact, selectionContact, null, null, null);
                        cursorContact.moveToFirst();
                        long idContact = cursorContact.getLong(0);
                        photo = openPhoto(idContact);
                        if (photo != null)
                            listContact.add(new CreateContactAdapter(contact, numero, body, id, photo, read));
                        else
                            listContact.add(new CreateContactAdapter(contact, numero, body, id, null, read));
                    } else {

                        listContact.add(new CreateContactAdapter("no", numero, body, id, null, read));
                    }
                    idList.add(id);
                }
                cursor.moveToNext();
            }
        }
        cursor.close();
        adapter = new ContactAdapter(listContact, this);
    }

    private void ConfigToolbar() {
        setSupportActionBar(toolbar);
        if (messageUnread > 0)
            getSupportActionBar().setTitle("Messages (" + messageUnread + ")");
        else
            getSupportActionBar().setTitle("Messages");
    }

    public byte[] openPhoto(long contactId) {
        Uri contactUri  = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId);
        Uri photoUri    = Uri.withAppendedPath(contactUri, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
        Cursor cursor   = getContentResolver().query(photoUri, new String[]{ContactsContract.Contacts.Photo.PHOTO}, null, null, null);
        if (cursor == null) {
            return null;
        }
        try {
            if (cursor.moveToFirst()) {
                byte[] data = cursor.getBlob(0);
                if (data != null) {
                    return data;
                }
            }
        } finally {
            cursor.close();
        }
        return null;
    }

    private void markMessageRead(Context context, String number, String body) {

        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        try {

            while (cursor.moveToNext()) {
                if ((cursor.getString(cursor.getColumnIndex("address")).equals(number)) && (cursor.getInt(cursor.getColumnIndex("read")) == 0)) {
                    if (cursor.getString(cursor.getColumnIndex("body")).startsWith(body)) {
                        String SmsMessageId = cursor.getString(cursor.getColumnIndex("_id"));
                        ContentValues values = new ContentValues();
                        values.put("read", true);
                        context.getContentResolver().update(Uri.parse("content://sms/inbox"), values, "_id=" + SmsMessageId, null);
                        return;
                    }
                }
            }
        } catch (Exception e) {
            Log.e("Mark Read", "Error in Read: " + e.toString());
        }
    }

    public ArrayList<String> getDifferentNumber(String number) {
        ArrayList<String> num = new ArrayList<>();
        if (number.matches("^[06|07]{2}[0-9]{8}")) {
            num.add(number.replaceAll(".{2}", "$0 "));
            num.add(number.replaceAll("06", "+336"));
            num.add(number.replaceAll(".{2}", "$0 ").replaceAll("0", "+33 "));
            num.add(number);
        } else if (number.matches("[06|07]{2}( [0-9]{2}){4}")) {
            num.add(number.replaceAll(" ", ""));
            num.add(number.replaceAll("0", "+33 "));
            num.add(number.replaceAll(" ", "").replaceAll("0", "+33"));
            num.add(number);
        } else if (number.matches("\\+[3]{2}[0-9]{8}.")) {
            num.add(number.replaceAll("\\+33", "0"));
            num.add(number.replaceAll("\\+33", "0").replaceAll(".{2}", "$0 "));
            num.add(number.replaceAll("\\+33", "0").replaceAll(".{2}", "$0 ").replaceAll("^0", "+33 "));
            num.add(number);
        } else if (number.matches("\\+33 [6|7]( [0-9]{2}){4}")) {
            num.add(number.replaceAll(" ", ""));
            num.add(number.replaceAll(" ", "").replaceAll("\\+33", "0"));
            num.add(number.replaceAll(" ", "").replaceAll("\\+33", "0").replaceAll(".{2}", "$0 "));
            num.add(number);
        } else {
            num.add(numero);
            num.add(numero);
            num.add(numero);
            num.add(numero);
        }
        return num;
    }

    public boolean edit(MenuItem item) {
        // actions
        return true;
    }

    public boolean newMessage(MenuItem item) {
        startActivity(new Intent(this, NewMessage.class));
        return true;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()){
                case R.id.setting :
                    startActivity(new Intent(this, Apparence.class));
            }
        return true;
    }

    @Override
    protected void onPause() {
        super.onPause();
        runMain = false;
    }
}

解决方案

Try adding the following to your styles.xml:

<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">@color/my_primary_color</item>
    <item name="colorPrimaryDark">@color/my_primary_dark_color</item>
    <item name="colorAccent">@color/my_accent_color</item>
    <item name="windowActionModeOverlay">true</item>

</style>

这篇关于我有2栏时,多选择列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆