小编ios*_*per的帖子

如何从自定义视图启动一个活动

如何从另一个视图启动一个活动(另一个活动视图)

例如,

public class CorrectSmoothGloflo extends Activity {
  .......................
  setContentView(new Panel(this));
}


public class Panel extends View {

   //This view class contains some drawable operation
   // Here i want to start another Activity like this

   Intent i=new Intent(CorrectSmoothGloflo.this,Screen.class);
    startActivity(i);   
}
Run Code Online (Sandbox Code Playgroud)

我不能做这个操作.因为这是View,所以不起作用,因为View没有startActivity().怎么实现这个?请给出一些指导.

android view android-intent android-activity

13
推荐指数
1
解决办法
7114
查看次数

如何从HashMap中计算相同的值?

如何从HashMAP中计算相同的值?

HashMap<HashMap<String, Float>, String> HM=new HashMap<HashMap<String,Float>, String>(); 

HashMap<String, Float> h;

h=new HashMap<String, Float>();                          
h.put("X", 48.0f);
h.put("Y", 80.0f);    
HM.put(typeValuesHM, "Red");

h=new HashMap<String, Float>();
h.put("X", 192.0f);
h.put("Y", 80.0f);
HM.put(typeValuesHM, "Red");

h=new HashMap<String, Float>();
h.put("X", 192.0f);
h.put("Y", 320.0f);
HM.put(typeValuesHM, "Blue");

h=new HashMap<String, Float>();
h.put("X", 336.0f);
h.put("Y", 560.0f);
HM.put(typeValuesHM, "Blue");
Run Code Online (Sandbox Code Playgroud)

我的HashMap HM的值如下:

{ {x=48,y=80}=Red,{x=192,y=80}=Red,{x=192,y=320}=Blue,{x=336,y=560}=Blue }
Run Code Online (Sandbox Code Playgroud)

这里,

我想计算HashMap HM中的相似值.

ie)如果我给值等于"红色"意味着我想得到count = 2.如果我给值等于"蓝色"意味着我想得到数= 2.

如何从HashMAP HM计算相同的值?

java android hashmap

8
推荐指数
2
解决办法
2万
查看次数

在Android中显示屏幕的TextView底部

在我的应用程序中,我想在屏幕顶部显示一个带有屏幕宽度的TextView.接下来要在TextView下面显示图形视图.接下来在图形视图下方显示一个文本视图.

我使用了以下xml代码.在我的代码中,TextView无法显示在screeen的底部.

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView  
android:orientation="horizontal"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello"
android:background="#FF8A11"
android:padding="8dip"
/>
</LinearLayout>



<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<com.game.viewdot.ViewDot
 android:id="@+id/DrawView"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 />   
 </LinearLayout>



 <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_gravity="bottom"  
>

<TextView  

android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Another Text View"
android:background="#FF8A11"
android:padding="8dip"
android:gravity="bottom"
 android:layout_gravity="bottom"
/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我希望在此代码中进行哪些修改以获得我的结果??????

layout android textview

8
推荐指数
2
解决办法
4万
查看次数