我使用了edittext而不是focauseble软键板我有什么问题。如何解决?我的代码如下。
我的Xml代码::
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative_sendimage_send"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true" >
<com.buymysari.SegmentedRadioGroup
android:id="@+id/segment_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:checkedButton="@+id/button_one"
android:orientation="horizontal" >
<RadioButton
android:id="@id/button_one"
android:layout_margin="15dip"
android:button="@null"
android:gravity="center"
android:minHeight="80dip"
android:minWidth="80dip"
android:text="S"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/radio_colors" />
<RadioButton
android:id="@+id/button_two"
android:layout_margin="15dip"
android:button="@null"
android:gravity="center"
android:minHeight="80dip"
android:minWidth="80dip"
android:text="C"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/radio_colors" />
<RadioButton
android:id="@+id/button_three"
android:layout_margin="15dip"
android:button="@null"
android:gravity="center"
android:minHeight="80dip"
android:minWidth="80dip"
android:text="A"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/radio_colors" />
</com.buymysari.SegmentedRadioGroup>
<com.buymysari.SegmentedRadioGroupMale
android:id="@+id/segment_text_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/segment_text"
android:layout_marginTop="20dip"
android:checkedButton="@+id/button_one_male"
android:orientation="horizontal" >
<RadioButton
android:id="@id/button_one_male"
android:layout_margin="15dip"
android:button="@null"
android:gravity="center"
android:minHeight="80dip"
android:minWidth="80dip"
android:text="M"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/radio_colors" />
<RadioButton
android:id="@+id/button_one_female"
android:layout_margin="15dip"
android:button="@null"
android:gravity="center"
android:minHeight="80dip"
android:minWidth="80dip"
android:text="F"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/radio_colors" />
</com.buymysari.SegmentedRadioGroupMale>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/segment_text_male"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dip" >
<EditText
android:id="@+id/edt_text_store_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"
android:hint="Name" />
<Button
android:id="@+id/btn_send_image"
android:layout_width="80dip"
android:layout_height="100dip"
android:layout_below="@+id/edt_text_store_name"
android:layout_marginTop="20dip"
android:text="send" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
我使用Fragment :::
public class SendImageServerFragment extends Fragment {
SegmentedRadioGroup segmentText;
SegmentedRadioGroupMale segmentTextMale;
Button sendImg;
EditText edt_txt;
MyApplication app;
View view;
Bundle bundle;
byte[] path;
String base64string = "";
Bitmap b;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}
view = inflater.inflate(R.layout.sendimageserver, null);
bundle = this.getArguments();
path = bundle.getByteArray("position");
segmentText = (SegmentedRadioGroup) view
.findViewById(R.id.segment_text);
segmentTextMale = (SegmentedRadioGroupMale) view
.findViewById(R.id.segment_text_male);
sendImg = (Button) view.findViewById(R.id.btn_send_image);
edt_txt = (EditText) view.findViewById(R.id.edt_text_store_name);
app = (MyApplication) getActivity().getApplicationContext();
sendImg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int segTxt = segmentText.getCheckedRadioButtonId();
RadioButton radiocatButton = (RadioButton) view
.findViewById(segTxt);
int segmentTextMaleTxt = segmentTextMale
.getCheckedRadioButtonId();
RadioButton radioSexButton = (RadioButton) view
.findViewById(segmentTextMaleTxt);
b = BitmapFactory.decodeByteArray(path, 0,path.length);
base64string = Base64.encodeToString(path, Base64.DEFAULT);
Log.v("log_tag", "base64string :: "+base64string);
}
});
return view;
}
}
答案 0 :(得分:1)
查看此帖子。显然存在问题,您需要在onCreateView()之后更改键盘。
SoftKeyboard does not display for a newly displayed Fragment
答案 1 :(得分:0)
试试这个
<EditText
android:id="@+id/edt_text_store_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:focusable="true"
android:focusableInTouchMode="true"
android:cursorVisible="true"
android:hint="Name" >
<requestFocus />
</EditText>