当前位置: 代码迷 >> Android >> android新手有关问题送分了
  详细解决方案

android新手有关问题送分了

热度:104   发布时间:2016-05-01 22:02:10.0
android新手问题送分了
最近在做个聊天软件 实现了弹出表情选择表情插入EditText
现在想实现用快捷键显示表情 像QQ一样输入/wx 就出现一个微笑表情 
实现了写/wx出现微笑表情 接着写/wx就不行了 我郁闷了 帅哥.美女们帮帮忙
代码如下
Java code
  public class MainActivity extends Activity {    private static String TAG="MainActivity";    private Button expressionButton;    private LayoutInflater inflater;    private GridView mGridView;    private EditText et;    private Dialog dialog;    //预定义的系统表情    private int[]face=new int[]    {        R.drawable.smiley_b_close,R.drawable.smiley_colon_apostrophe_open,            R.drawable.smiley_colon_close,R.drawable.smiley_colon_d,            R.drawable.smiley_colon_dollar,R.drawable.smiley_colon_e,            R.drawable.smiley_colon_o,R.drawable.smiley_colon_open,            R.drawable.smiley_colon_p,R.drawable.smiley_colon_pipe,            R.drawable.smiley_colon_s,R.drawable.smiley_colon_slash,            R.drawable.smiley_colon_star,R.drawable.smiley_colon_three,            R.drawable.smiley_colon_x,R.drawable.smiley_greater_than_colon_open,            R.drawable.smiley_kik,R.drawable.smiley_less_than_slash_three,            R.drawable.smiley_less_than_three,R.drawable.smiley_semicolon_close    };        private ImageGetter imageGetter = new ImageGetter() {                @Override        public Drawable getDrawable(String source) {            int id = Integer.parseInt(source);            Drawable draw = getResources().getDrawable(id);            draw.setBounds(0, 0, draw.getIntrinsicWidth(), draw.getIntrinsicHeight());            return draw;        }    };        @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);                et=(EditText) findViewById(R.id.EditText1);        expressionButton = (Button) findViewById(R.id.expressionButton);        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);        View layout = inflater.inflate(R.layout.customdialog, null);        //获取自定义对话框中的GridView        mGridView  = (GridView) layout.findViewById(R.id.gridview);        mGridView.setAdapter(new ImageAdapter(MainActivity.this));                //使用快捷键快速出现表情        et.setOnKeyListener(new EditText.OnKeyListener() {                        @Override            public boolean onKey(View v, int keyCode, KeyEvent event) {                EditText ev = (EditText) v;                String s_ev = ev.getText().toString().trim();                //Log.i(TAG, s_ev);                //Log.i(TAG, ExpressShortCut.AX_POSITION+"");                    if(s_ev.equals(ExpressShortCut.SYSTEM_EXPRESS_MJ)) {                        et.setText("");                        et.append(Html.fromHtml("<img src='"+face[ExpressShortCut.MJ_POSITION]+"'/>",imageGetter,null));                    }return false;            }});

再次在这里谢谢昨天帮忙的帅哥美女们 我爱你们

------解决方案--------------------
快乐接分!
------解决方案--------------------
没做过IM,帮你顶下,纯粹接分,
------解决方案--------------------
以前看过一点,android中有mutilTextAutoComplete这个属性,可以看下,这里面还有些东西的,我在and pro 2 中看到的
------解决方案--------------------
没做过
------解决方案--------------------
android中mutilTextAutoComplete这个属性
------解决方案--------------------
没做过 顶下 来接分!!!!!!
  相关解决方案