我必须在android TextView上以编程方式设置背景
我使用下面的code.its不工作,它也给了我nullpointerexception错误.
best_deals = (TextView) findViewById(R.id.bestdeals);
best_deals.setBackground(getResources().getDrawable(
R.drawable.headerradius));
Run Code Online (Sandbox Code Playgroud)
但我必须把这些
best_deals.setTextColor(Color.parseColor("#be2351")); 意味着它的工作
上面的代码有什么问题??? 请给我这些解决方案..
这是我的header_redius.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#000000"/>
<corners
android:radius="15dp"
/>
<gradient
android:startColor="#434343"
android:centerColor="#434343"
android:endColor="#434343"
android:angle="270"
android:type="linear"
/>
<padding android:left="10dp"
android:top="0dp"
android:right="10dp"
android:bottom="0dp"/>
<stroke
android:width="2dp"
android:color="#000000" />
</shape>
Run Code Online (Sandbox Code Playgroud) 我必须开发一个Android应用程序.
这里我遵循以下xml格式.
<Product>
<product name="viki" productid="111">
<ProductType>
<producttype>Nokia</producttype>
<producttype>Samsung</producttype>
</ProductType>
</product>
</Product>
Run Code Online (Sandbox Code Playgroud)
在这里,我必须获得particluar product的产品类型.所以我写了以下代码:
if(subCategoryChildNode.hasChildNodes()){
// parse 'Subcategory' childs
NodeList productNL = subCategoryChildElmt.getElementsByTagName("product");
if(productNL.getLength() > 0){
ArrayList<Product> productAL = new ArrayList<Product>();
Product productBean = null;
for(int pCnt=0;pCnt<productNL.getLength();pCnt++){
Node productNode = productNL.item(pCnt);
Element productElmt = null;
// parse 'product' tag attributes
if(productNode.hasAttributes()){
productBean = new Product();
productElmt = (Element)productNode;
productBean.setmProductName(productElmt.getAttribute("name"));
}
if(productNode.hasChildNodes()){
NodeList productTypeNL = productElmt.getElementsByTagName("ProductType");
if(productTypeNL.getLength() > 0){
ArrayList<ProductType> ProductTypeAL = new ArrayList<ProductType>();
ProductType productTypeBean = null;
for(int ptCnt=0;ptCnt<productTypeNL.getLength();ptCnt++){
Node …Run Code Online (Sandbox Code Playgroud) 我必须开发一个Android应用程序.
我创建了一个使用include标签使用另一个布局文件的布局文件.
<include
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
layout="@layout/footer_tabs" />
<include
android:id="@+id/footer1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
layout="@layout/footertabs" />
Run Code Online (Sandbox Code Playgroud)
我想在响应为空时显示包含的布局,否则我想隐藏布局并显示另一个.这是我到目前为止:
footertabs = (RelativeLayout) findViewById(R.id.footertab);
footer_tabs = (RelativeLayout) findViewById(R.id.footer_tab);
if (Constants.response==null) {
footertabs.setVisibility(View.VISIBLE);
footer_tabs.setVisibility(View.GONE);
}
else
{
footertabs.setVisibility(View.GONE);
footer_tabs.setVisibility(View.VISIBLE);
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
07-15 17:19:09.893: E/AndroidRuntime(15143): Caused by: java.lang.NullPointerException
07-15 17:19:09.893: E/AndroidRuntime(15143): at com.example.androidbestinuk.HomePage.onCreate(HomePage.java:56)
Run Code Online (Sandbox Code Playgroud)
请帮我调试这个错误.
我必须开发一个Android应用程序.
在这里,我必须开发一个Twitter集成Android应用程序.
我使用下面的代码:
public void onClickTwitt() {
if (isNetworkAvailable()) {
Twitt twitt = new Twitt(getActivity(), consumer_key, secret_key);
twitt.shareToTwitter(_Title);
} else {
showToast("No Network Connection Available !!!");
}
}
public boolean isNetworkAvailable() {
ConnectivityManager connectivity =(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
这里得到以下错误: …
我遇到以下两个问题:
第一个问题:
我必须注册两个使用相同设备的客户,因此他们具有相同的注册ID.
当我从服务器端向这两个客户发送报价时,显示的通知应取决于登录的客户.
例如(见图):
在我的申请表中,我有一个客户登录表单.在这种形式下,如果用户gnanavel登录,则应用程序必须单独接收其优惠,而不是其他优惠.
同样,如果用户jeya登录,则应用程序必须单独接收她的优惠,而不是其他优惠.
目前该应用程序正在接收这两个优惠
编辑:
我已经在我的数据库中创建了登录状态字段.如果我的客户登录设备意味着收到了他的报价单独的通知.我没有得到其他的报价.工作得很好.
我点击了优惠按钮检查了条件:
$getregid = mysqli_query($con,"select * from pim_customers where customer_id='$customer_id' and gcm_regid='$regId' and loginstatus='Y'");
Run Code Online (Sandbox Code Playgroud)
我写这些条件意味着我的第一个问题得到了解决.但提出了另一个问题.
的另一个问题是,
当管理员输入某些要约时,客户只有在登录客户时才必须在设备上接收通知.否则,不应收到通知.这部分运作良好.
问题是,当我的客户长时间注销时,管理员会在此期间输入更多优惠.
如果客户在2天后登录应用程序,他应该收到所有待处理的消息.如何获取待处理的消息?
管理员端输入提供的时间客户注销意味着loginstatus在数据库中是'N'.那么如何执行这些条件并接收通知.
$getregid = mysqli_query($con,"select * from pim_customers where customer_id='$customer_id' and gcm_regid='$regId' and loginstatus='Y'");
Run Code Online (Sandbox Code Playgroud)
这是单击商品按钮时执行的服务器端代码:
if (isset($_GET["regId"]) && isset($_GET["customer_id"]) && isset($_GET["message"])) {
$regId = $_GET["regId"];
$message = $_GET["message"];
$customer_id = $_GET["customer_id"];
include_once './GCM.php';
$getregid = mysqli_query($con,"select * from pim_customers where customer_id='$customer_id' and gcm_regid='$regId' and loginstatus='Y'");
$count1=mysqli_num_rows($getregid);
while($row …Run Code Online (Sandbox Code Playgroud) php android push-notification intentservice google-cloud-messaging
我必须开发一个Android应用程序.
我创建了一个警告对话框.如果我必须旋转方向意味着警报对话框消失.
但是我想在方向改变时显示警告对话框.
@Override
public void onConfigurationChanged ( Configuration newConfig )
{
super.onConfigurationChanged(newConfig);
try
{
MainActivity.editCalled = true;
Intent in = new Intent(AndroidListFragmentActivity.this, AndroidListFragmentActivity.class);
startActivity(in);
finish();
}
catch (Exception e)
{
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我使用了两个片段......
在第二个片段中有一个警告对话框:
ImageView share = (ImageView) findViewById(R.id.imageView5);
share.setOnClickListener(new OnClickListener()
{
public void onClick ( View v )
{
final CharSequence[] items =
{
"Facebook", "Twitter", "Email"
};
AlertDialog.Builder builder = new AlertDialog.Builder(SubCate.this);
builder.setTitle("Share Via:");
builder.setItems(items, new DialogInterface.OnClickListener()
{
public void onClick ( DialogInterface dialog , int …Run Code Online (Sandbox Code Playgroud) 我必须为 edittext 创建背景颜色意味着正确获取背景。
TestPost.this.findViewById(R.id.revieew)
.setBackgroundColor(color);
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能获得这些 edittext 的 textcolor 。
TestPost.this.findViewById(R.id.revieew)
.setTextColor(color);
Run Code Online (Sandbox Code Playgroud)
请给我一个解决方案???
我必须选择绿色意味着必须输入文本为绿色....在这里我已经为背景颜色做了这些。我必须将背景颜色设置为绿色意味着必须从颜色选择器中选择绿色意味着 bexkground正在成功显示...如何从颜色选择器设置文本颜色???
编辑:
reviewEdit.setTextColor(color);
Run Code Online (Sandbox Code Playgroud)
意味着我得到的颜色是成功的...但我没有改变整个文本。
我想单独更改所选文本的颜色...
对于 EG:
文字是:客户正在等待您的回复的意思
必须选择绿色,必须写 客户正在等待必须单独为这些文本显示绿色。之后必须选择颜色粉红色意味着必须将您的回复显示为粉红色。
这正是我需要的......我该如何实现这些???
我开发了一个应用程序。在这里,我必须在ArrayList. 如果我必须点击Button意味着价值必须增加ArrayList。我必须单击另一个Button表示添加的列表正在显示。我能怎么做?请给我解决方案。
这些是我的价值观:
product_id = getIntent().getStringExtra("id");
product_title = getIntent().getStringExtra("title");
product_image = getIntent().getStringExtra("image");
product_price = getIntent().getStringExtra("price");
product_desc = getIntent().getStringExtra("description");
arrayList = new ArrayList<String>();
arrayList.add(product_title);
arrayList.add(product_price);
arrayList.add(product_id);
arrayList.add(product_image);
arrayList.add(product_desc);
Run Code Online (Sandbox Code Playgroud)
我必须ArrayList在单击时添加这些值Button:
valueaddlist = (Button) findViewById(R.id.valueaddlist);
valueaddlist.setOnClickListener(new OnClickListener() {
public void onClick(View v){
Intent intent = new Intent(this,AddedListProducts.class);
intent.putExtra("WishListProducts", arrayList);
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
在AddedListProducts必须显示所有添加的产品列表中。
我能怎么做 ?请给我解决这些问题?
编辑:
这是我的 AddListProducts 类代码:
wishlist_products = (ListView) findViewById(R.id.wishlist_products);
if(getIntent().getExtras() !=null){
WishListProducts = (ArrayList<String>) getIntent().getExtras().getSerializable("WishListProducts");
System.out.println(WishListProducts); …Run Code Online (Sandbox Code Playgroud) android ×8
java ×3
arraylist ×1
background ×1
connectivity ×1
domparser ×1
gradient ×1
include ×1
networking ×1
php ×1
textcolor ×1
textview ×1
xml-parsing ×1