Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RadioButton阿拉伯语(左侧文本)编程_Android_Android Layout - Fatal编程技术网

Android RadioButton阿拉伯语(左侧文本)编程

Android RadioButton阿拉伯语(左侧文本)编程,android,android-layout,Android,Android Layout,我需要在一个单选组中动态创建RadioButton,在XML中已经定义了单选组,在我进行研究后,我发现了一些主题,可以将android:drawableRight=“@android:drawable/btn_Radio”和android:button=“@null”放在XML中,我如何通过编程实现它们 这是我的密码: final RadioGroup RG =(RadioGroup) vi.findViewById(R.id.RG); RG.removeAllViews(); Strin

我需要在一个单选组中动态创建RadioButton,在XML中已经定义了单选组,在我进行研究后,我发现了一些主题,可以将
android:drawableRight=“@android:drawable/btn_Radio”
android:button=“@null”
放在XML中,我如何通过编程实现它们

这是我的密码:

 final RadioGroup RG =(RadioGroup) vi.findViewById(R.id.RG);
 RG.removeAllViews();
 String[] answers= null;
 answers=item.Answers.split(";");
 final TextView txtTitle = (TextView) vi.findViewById(R.id.QuestionRow);
 txtTitle.setText(item.Question);
 for (int i=0;i<answers.length;i++){             

      RadioButton bt=null; 
      bt = new RadioButton(parent.getContext());
      bt.setId(i+1);
      bt.setText(answers[i]);    
      bt.setGravity(Gravity.RIGHT);             
      RG.addView(bt);
 }
final RadioGroup RG=(RadioGroup)vi.findViewById(R.id.RG);
RG.removeallview();
字符串[]answers=null;
answers=item.answers.split(“;”);
最终文本视图txtTitle=(文本视图)vi.findViewById(R.id.QuestionRow);
txtTitle.setText(项目.问题);
对于(int i=0;i
protectedvoid onPostExecute(HashMap mylist){
//TODO自动生成的方法存根
super.onPostExecute(mylist);

对于(整数z=0;z欢迎使用StackOverflow!您尝试了什么?您阅读了文档吗?
setButtonDrawable
?代码位于填充列表视图的适配器内,默认情况下Radiobutton在右侧显示其文本我需要的是在左侧显示文本,因为阿拉伯语书写从右向左开始,我需要转换drawableRight abd android:button进入代码…不,我没有读过关于setButtonDrawable的文档,我什么时候可以找到它?如果你以这个链接为例(),他使用的是XML中预定义的单选按钮,但我需要做同样的事情,但是使用由代码动态创建的单选按钮
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Questionlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@color/White" >

 <TextView
     android:id="@+id/QuestionRow"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
     android:layout_alignParentTop="true"
     android:gravity="right"
     android:textColor="@color/black_overlay"
     android:textSize="30sp"
     android:textStyle="bold" />

 <RadioGroup 
     android:id="@+id/RG" 
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:gravity="right"  
     android:layout_below="@+id/QuestionRow"
     android:layout_alignRight="@+id/QuestionRow"        
     ></RadioGroup>

 <Button
     android:id="@+id/Vote"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_below="@+id/RG"
     android:text="Vote" />

 <Button
     android:id="@+id/button1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_centerHorizontal="true"
     android:layout_below="@+id/RG"
     android:text="See Statistics" />

 </RelativeLayout>
protected void onPostExecute(HashMap<String,String> mylist) {
        // TODO Auto-generated method stub
        super.onPostExecute(mylist);
         for(Integer z=0;z<mRG.getChildCount();z++){
            View o =mRG.getChildAt(z);
            ((RadioButton)o).setText(text[z]);







    }

         for(Integer z =0;z< mRG.getChildCount();z++){

             Set set = mylist.entrySet(); 
                Iterator i = set.iterator(); 
             View o = mRG.getChildAt(z);

              NumberFormat formatter = new DecimalFormat("#0.00");

             if (o instanceof RadioButton){


             int counted[] = new int[ mRG.getChildCount()];
             int j=0;
             while(i.hasNext()) { 


    enter code here
                    Map.Entry me = (Map.Entry)i.next(); 
                    String Value=String.valueOf(formatter.format(Double.valueOf(me.getValue().toString())*100/count))+"%";
                    if (Integer.valueOf(me.getKey().toString())==((RadioButton) o).getId())
                    {

                        ((RadioButton)o).setText(text[z]+" "+ Value);
                    }



             }
         }
         }
         progressDialog.hide();
    }