我有两节课.首先是活动,第二是我有一些片段EditText
.在活动中我有一个带有async-task的子类,在方法中doInBackground
我得到一些结果,我保存到变量.如何将此变量从子类"my activity"发送到此片段?
我有一个大的布局,里面有一个较小的布局.
如何在小布局周围创建线条边框?
弹出窗口有问题.我想用自己的布局创建弹出窗口.这是代码:
public class PopupWindowView extends PopupWindow{
PopupWindow popup;
boolean click = true;
LayoutParams params;
RelativeLayout mainLayout;
TextView tv;
LinearLayout layout;
ImageView chooseFlag;
public void createPopupWindow(Activity act){
popup = new PopupWindow(act);
chooseFlag = (ImageView) act.findViewById(R.id.login_choose_flag);
mainLayout = (RelativeLayout) act.findViewById(R.id.login_layout);
tv = new TextView(act);
layout = new LinearLayout(act);
//layout = (LinearLayout) findViewById(R.id.popuplayout);
chooseFlag.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (click) {
int[] values = new int[2];
v.getLocationOnScreen(values);
popup.showAtLocation(mainLayout, Gravity.NO_GRAVITY, 10, 10);
popup.update(values[0], values[1], 300, 80);
click = false;
} …
Run Code Online (Sandbox Code Playgroud) 我Theme.Black
在我的应用程序中使用应用程序主题.在这个主题中,动作栏是灰色的.我如何改变动作栏的颜色?这是我的尝试:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="mytheme" parent="@android:style/Theme.Black" >
</style>
<style name="Widget.MyApp.ActionBar" parent="@android:style/Widget.ActionBar">
<item name="android:background">@android:color/black</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
但是,它不起作用.有任何想法吗?
我的TextView
宽度为wrap content
.在这个TextView
我设置文本,但文本每次都不是相同的长度.当文本很长时,我使用单行true和ellipsize
:end.但现在我有一个问题.我想设置其他布局的可见性,但这取决于我的文本的长度.如果文本太长而无法放入屏幕我想setVisible为true,但是当文本很短并且我不需要ellipsize时,我想将可见性设置为false.所以我需要检查TextView的状态.当它的椭圆形时我想要setVisible
真实,当它不是setVisible
假的.我怎么能这样做 这就是我得到的:
tvAle.post(new Runnable() {
@Override
public void run() {
int lineCount = tvAle.getLineCount();
Paint paint = new Paint();
paint.setTextSize(tvAle.getTextSize());
final float size = paint.measureText(tvAle.getText().toString());
Log.v("a", ""+size+" "+tvAle.getWidth());
if ((int)size > (tvAle.getWidth()+10)) {
allergiesLayout.setVisibility(View.VISIBLE);
}
else
allergiesLayout.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)
但这个解决方案不起作用.
我想问你textview是否有任何选项,当我有太长的文本时,例如文本有30 dp而textview有15 dp我想显示从左上角移动到右边并返回到开始和再次的文本.像动画一样的东西.我想用户看到所有文字.像自动滚动的东西.
编辑:我怎么能在代码中,而不是xml?
我有一个scrollview布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:fadingEdge="none"
android:overScrollMode="never"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="100"
android:background="@color/antiquewhite">
<LinearLayout
android:id="@+id/top_layou"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="15"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="25dp"
android:background="@color/bisque">
<TextView
android:id="@+id/title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="15dp"
android:text="@string/user_information_text"
android:textSize="26dp"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:id="@+id/subtitle_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="5dp"
android:text="@string/user_information_subtitle_text"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="@color/black"/>
</LinearLayout>
<LinearLayout
android:id="@+id/body_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="85"
android:orientation="horizontal"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:weightSum="100"
>
<LinearLayout
android:id="@+id/left_part"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="50"
android:weightSum="100"
android:background="@color/antiquewhiter">
<TextView
android:id="@+id/first_name_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dp"
android:layout_marginTop="30dp"
android:text="@string/first_name_text"
style="@style/bold_text18"
/>
<LinearLayout
android:id="@+id/first_name_edit_layout"
android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud) 我有一个小问题.我有一个ArrayList listOfSData,其中每个元素都像日期一样:例如:
[30-03-2012,28-03-2013,31-03-2012,2-04-2012,...]
现在我想知道如何对此列表进行排序.我的意思是我想要解决这个问题
[28-03-2013,30-03-2012,31-03-2012,2-04-2012等].
此列表必须具有String值.我该如何排序这个清单?帮助我,因为我不知道我该怎么做.
我和json有问题.我希望我的Json看起来像:
data={"phoneId":1,"token":"APA91bF2tN5g1TtULFE5tysRMAarygjX4w9hjTGCqT3SL-PwiMV6aqTtkV3lpqLkc7msVfEdTnyd_pJVFNMM_fjEbeVSuCjiNPVKx7p9sYC1DoWnuKUurt31E1yh2RDwl_oprfKxEF18PP6Q8dXHZe6FeflE3CIxBg","appId":5}
Run Code Online (Sandbox Code Playgroud)
这是我的帖子到网络服务:
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", regId);
jsonObject.put("appId", GlobalConfig.getAPPLICATION_ID());
jsonObject.put("phoneId", 1);
JSONArray jArrayParam = new JSONArray();
jArrayParam.put(jsonObject);
JSONObject finaljsonobj = new JSONObject();
finaljsonobj.put("data", jArrayParam);
System.out.println(jsonObject.toString());
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("Token",jArrayParam.toString()));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(GlobalConfig.getSendEmail());
httppost.addHeader("Authorization", "Basic " + Base64.encodeToString(
(GlobalConfig.getAuthString()).getBytes(),Base64.NO_WRAP));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePair, HTTP.UTF_8));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Run Code Online (Sandbox Code Playgroud)
如何在我的例子中检查我的json是否像一个?我想查看我的json如何发布到webservice.
我有一点问题.我想以其他方式开始活动.我知道
Intent i = new Intent(this, ActivityTwo.class);
Run Code Online (Sandbox Code Playgroud)
初始化意图,之后我可以startActivity
.但我想做那样的事情:
Intent i = new Intent(this, MyString.class);
Run Code Online (Sandbox Code Playgroud)
我没有nameActivity.class
,但我想在string.class上进行更改.当我有类的字符串名称时,如何启动活动?