cocos2d-x Jni c++ java互调 并且相互刷新UI控件最简单例子(下
c++ 调用java 篇:
c++调用java。同事刷新android的Edit View控件
第一步:
第二步:创建布局文件
第三步:
public static EditText myView;
第四步:添加文本输入框
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
myView =(EditText)LayoutInflater.from(this).inflate(R.layout.myedit,framelayout,false);
myView.addTextChangedListener(watcher);
myView.setMovementMethod(ScrollingMovementMethod.getInstance());
framelayout.addView(myView);
第五步:添加监听
TextWatcher watcher = new TextWatcher()
{
@Override
public void afterTextChanged(Editable s)
{
// TODO Auto-generated method stub
Log.d(TAG,111111);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
// TODO Auto-generated method stub
Log.d(TAG,22222);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
Log.d(TAG,33==[TextWatcher][onTextChanged]+s);
}
};
第六步:
public static void hideAdView(String[] str)
{
mHandler.obtainMessage( 100, str ).sendToTarget();
}
private static HandlermHandler =new Handler()
{
public void handleMessage(Message msg)
{
switch (msg.what)
{
case 100://UPDATE_UI:
{
String[] arrStrings = (String[])msg.obj;
if(arrStrings[0].equals(I'm a titile))
{
TestJni.this.myView.setText(C++ Change Java EditView string Test!);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>