Tag: android layout

Android布局和定位问题

最近我正在构建一个应用程序,现在我有一些布局和定位的问题。 事实上,我构建我的布局,但当我在更大的屏幕上测试时,一切都崩溃了,我的应用程序看起来并不好。 生成UI的最佳方法是什么?

为什么LocalBroadCastManager从IntentService发送的意图没有被Activity类中的BroadCastReceiver接收?

ChooseLanguageFragment.java Intent explicitGetNumberServiceIntentUSA = new Intent(getActivity(), GetNumberService.class); explicitGetNumberServiceIntentUSA.putExtra(“country”, “USA”); getActivity().startService(explicitGetNumberServiceIntentUSA); 这就是GetNumberService的调用方式。 这是从GetNumberService.java传递arraylist的方式 Intent mobileNumbersIntent = new Intent(); mobileNumbersIntent.putStringArrayListExtra(“mobileNumbers”, mobileNumberList); mobileNumbersIntent.setAction(ChooseNumber1.MobileNumberBroadcastReceiver.MOBILE_NO_RECEIVER); mobileNumbersIntent.addCategory(Intent.CATEGORY_DEFAULT); mobileNumbersIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //this is needed when callling startActivity() outisde an Activity sendBroadcast(mobileNumbersIntent); 在onHandleIntent()方法中。 GetNumberService完美地完成了它的工作。 ChooseNumber1.java public class ChooseNumber1 extends AppCompatActivity { private MobileNumberBroadcastReceiver receiver; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); IntentFilter intentFilter = new […]

Android EditText提示使用与EditText相同的字体

我已经为EditText定义了一个字体,现在EditText提示也显示了该字体,但我需要为EditText提示使用不同的字体,有没有办法实现这一点?

在Android中访问ListView CheckBox

我正在android中创建一个待办事项列表应用程序。 一切都运行得很好,除了我在ListView中有复选框,我无法以编程方式设置。 我正在使用一个SQLite数据库来存储我的任务以及它们是否已标记为完成。 当我选中一个复选框时,它会在我的数据库中成功保存“1”。 我有一个updateUI方法,从我的数据库中读取我的任务文本并显示它。 我已经创建了一个新的“updateUICheckBox”方法来处理更新复选框的UI。 现在我只是试图将所有复选框设置为选中,但是当我调用setChecked(true)时,我得到一个nullpointerexception。 // not working private void updateUICheckBox() { CheckBox c = (CheckBox) findViewById(R.id.list_complete_check_box); c.setChecked(true); // null pointer exception }

设置LayoutParams 时出现NullPointerException

我想以编程方式添加一个按钮,也应该设置LayoutParams。 不幸的是,该应用程序提供了一个例外: java.lang.NullPointerException:尝试在空对象引用上写入字段’int android.view.ViewGroup $ LayoutParams.height’ 我不知道为什么。 你可以帮帮我吗? 这是我的代码。 Button b = new Button(getApplicationContext()); b.setText(R.string.klick); ViewGroup.LayoutParams params = b.getLayoutParams(); params.height = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.WRAP_CONTENT;

从服务器加载XML布局(android)

我对这个问题进行了大量研究,但我得不到我想要的答案。 所以我确实有一个应用程序从服务器获取字符串。 该系列字符串采用XML格式。 这是我将从服务器获得的一个示例(您可以看到它是一个布局): 这将根据将从服务器上载的xml文件进行更改。 我的问题是如何将这些字符串系列实现为布局并作为活动布局加载。 我想将它保存在xml文件中的设备的SD卡并加载它作为布局但我想在运行它后不可能重新编译代码。 有什么建议么? 谢谢。

android布局创建问题

我是Android开发的新手。 我创建了一个Android应用程序,以下是我的main.xml 我收到以下警告: This LinearLayout layout or its RelativeLayout parent is possibly useless; transfer the background attribute to the other view 任何人都可以告诉这个警告的原因和问题的解决方案。?

如何动态添加XML副本

我正在制作一个Android应用程序,我想在线性布局中复制一些XML代码,然后将其重新插入到线性布局中,以便线性布局中有两个相对布局。 我想通过以下代码动态地执行此操作: 然后简单地把它变成这样: 看看会有两个RelativeLayout部分…我想基本上复制一个然后再添加它(我真的不知道在我的程序中有多少次我可能要这样做,这就是为什么我我不是直接将它插入XML,我想从Java代码中完成它。 这是我到目前为止所做的,但每当我运行它时,布局都是错误的。 我的代码可能有什么问题? LinearLayout m3 = (LinearLayout)findViewById(R.id.tileContainerME); RelativeLayout m = (RelativeLayout)findViewById(R.id.tilesAreHERE); RelativeLayout m2 = new RelativeLayout(this); m2.setLayoutParams(m.getLayoutParams()); m2.setGravity(m.getGravity()); m2.setLayoutDirection(m.getLayoutDirection()); TextView et1 = (TextView) findViewById(R.id.bottom1); TextView et2 = (TextView) findViewById(R.id.left1); TextView et3 = (TextView) findViewById(R.id.right1); TextView et4 = (TextView) findViewById(R.id.top1); TextView tv1 = new TextView(et1.getContext()); TextView tv2 = new TextView(et2.getContext()); TextView tv3 = […]

如何在cardView中间实现之字形视图

我怎样才能实现CardView之类的东西 。 如果您仔细看到我的图像,您将会知道此问题不重复。 我检查了所有给定的链接,但他们没有解决我的问题。 我alredy尝试了这个和这个 ,但没有解决我的问题。 请帮我。 我搜索了每一个没有任何想法的地方。 请帮助我实现这一目标。 提前致谢。

如何在android中选择和取消选择图像?

我正在尝试写一个项目。 在我的项目中,我可以成功拖动图像。 这是PICTURE ,这是我的ViewOnTouchListener代码: package com.seifi.dragtestapplication; import android.graphics.Point; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; class ViewOnTouchListener implements View.OnTouchListener { Point pushPoint, closePoint; int lastImgLeft; int lastImgTop; FrameLayout.LayoutParams viewLP; FrameLayout.LayoutParams pushBtnLP; FrameLayout.LayoutParams closeBtnLP; int lastPushBtnLeft, lastCloseBtnLeft; int lastPushBtnTop, lastCloseBtnTop; private View mPushView, mCloseView, mShadowView; ViewOnTouchListener(View mPushView, View mCloseView, View mShadowView) { this.mPushView = mPushView; this.mCloseView = […]