我在Android中创建了一个视图,我需要从下到上为其设置动画,反之亦然.当我点击时,ImageView我需要RelativeLayout从底部到顶部动画完整,并且它成功了.但是,当我再次点击ImageView它并没有向下移动时.此外,当我点击其原始位置时,当我单击ImageView动画的原始位置时,但从RelativeLayout原始位置向下移动而不是从上到下.
这是我的代码:
ImageView iv_header;
RelativeLayout rl_footer;
boolean isBottom = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.rateus_layout);
rl_footer = (RelativeLayout) findViewById(R.id.rl_footer);
iv_header = (ImageView) findViewById(R.id.iv_up_arrow);
iv_header.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (isBottom) {
FooterAnimation();
isBottom = false;
} else {
headerAnimation();
isBottom = true;
}
}
});
}
public void FooterAnimation() {
Animation hide = …Run Code Online (Sandbox Code Playgroud) 点击图片视图时,我需要为我的相对布局设置动画.
1.从底部到顶部移动相对布局(在图像视图上单击时).
2.从上到下移动(在图像视图上再次单击时).
首先,当我点击图像视图时,它工作正常,相对布局从下到上向上移动,但是当我再次点击图像视图时,它从上到下是动画,当它到达原始位置时,它隐藏在我的活动上.帮助和提前谢谢.
这是我的活动:
public class MainActivity extends Activity {
RelativeLayout rl_footer;
ImageView iv_header;
boolean isBottom = true;
Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rl_footer = (RelativeLayout) findViewById(R.id.rl_footer);
iv_header = (ImageView) findViewById(R.id.iv_up_arrow);
iv_header.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
iv_header.setImageResource(R.drawable.down_arrow);
// iv_header.setVisibility(View.INVISIBLE);
// iv_down.setVisibility(View.VISIBLE);
iv_header.setPadding(0, 10, 0, 0); // substitute parameters for
// left, top, right, bottom
rl_footer.setBackgroundResource(R.drawable.up_manu_bar);
// FooterAnimation();
if (isBottom) {
FooterAnimation();
isBottom = false;
} …Run Code Online (Sandbox Code Playgroud) 我有以下文本文件到我的SdCard.now我想通过Json解析器解析这个文件,我想解析并读取这个文件并将数据显示到我的textview中,我该怎么做?
{
"data": [
{
"id": "1",
"title": "Farhan Shah",
"duration": 10,
},
{
"id": "2",
"title": "Noman Shah",
"duration": 10,
},
{
"id": "3",
"title": "Ahmad Shah",
"duration": 10,
},
{
"id": "4",
"title": "Mohsin Shah",
"duration": 10,
},
{
"id": "5",
"title": "Haris Shah",
"duration": 10,
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是代码:
File sdcard = Environment.getExternalStorageDirectory();
//Get the text file
File file = new File(sdcard,"textarabics.txt");
String UTF8 = "utf8";
int BUFFER_SIZE = 8192;
//Read text from file
StringBuilder text = …Run Code Online (Sandbox Code Playgroud) 这是我的logcat报告:
java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=2
at java.lang.String.startEndAndLength(String.java:583)
at java.lang.String.substring(String.java:1464)
at com.buzzador.profile.getValidPhoneNumber(profile.java:1966)
at com.buzzador.profile.setDataForServer(profile.java:1717)
at com.buzzador.profile$5.onClick(profile.java:236)
at android.view.View.performClick(View.java:4377)
at android.view.View$PerformClick.run(View.java:18044)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
我认为问题在于这个功能:
public String getValidPhoneNumber (String phoneNumber, String country)
{
String csValidPhoneNumber = "";
phoneNumber = getPhoneNumberWithoutReqularExpresions(phoneNumber);
phoneNumber = phoneNumber.replaceFirst ("^0*", "");
String csCountryCode = getCountryCode(country);
String csAppendedCode = phoneNumber.substring(0, csCountryCode.length());
if(csAppendedCode.equals(csCountryCode))
{
csValidPhoneNumber = "+" + phoneNumber;
return csValidPhoneNumber;
}
csValidPhoneNumber …Run Code Online (Sandbox Code Playgroud) 我需要像我在下面的图片中提到的价格范围搜索栏或滑块.任何帮助或示例代码将不胜感激.
提前致谢.
我开发了原生Android应用程序,现在要求开发的应用程序需要在Xamarin或Titanium Appcelerator等跨平台上,现在请一些专家软件工程师建议我应该选择哪个跨平台?为什么?如果我选择Xamarin那么Xamarin的优点和缺点是什么?如果我选择Titanium Appcelerator那么钛的优点和缺点是什么?任何帮助将受到高度赞赏.