如何在图像中显示列表项目时如何填充.我想在布局中制作分隔线,如图所示.
这是我的列表片段代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp">
<ListView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/listV_main"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"/>
Run Code Online (Sandbox Code Playgroud)
这是我的List部分代码
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp">
<include
android:id="@+id/list_item_section_text"
layout="@android:layout/preference_category"
/>
Run Code Online (Sandbox Code Playgroud)
这是我的清单项目代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:adjustViewBounds="true"
android:paddingRight="?android:attr/scrollbarSize"
>
<ImageView
android:id="@+id/showlist_item_entry_drawable"
android:layout_width="82dp"
android:adjustViewBounds="true"
android:layout_height="68dp"
android:scaleType="fitXY"
android:paddingLeft="9dp"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1"
>
<TextView android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/list_item_entry_title"
android:layout_alignLeft="@id/list_item_entry_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我已经为gridview编写了代码,我可以在其中显示图像和文本,但我想在单个可滚动的行中显示所有图像,如Pulse新闻应用程序.我已经在xml中为gridview实现了horizontalscroll-view,但它根本不起作用.我正在使用pageviwer选项卡,我正在使用片段.
这是我的xml代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="horizontal" >
<GridView
android:layout_width="500dp"
android:layout_height="400dp"
android:id="@+id/gridview"
android:columnWidth="300dp"
android:numColumns="3"
android:horizontalSpacing="10dp"
android:scrollbars="horizontal">
</GridView>
</HorizontalScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的图片adpator代码
public class ImageAdapter extends BaseAdapter {
private Context context;
private final String[] mobileValues;
private TextView t;
public ImageAdapter(Context context, String[] mobileValues) {
this.context = context;
this.mobileValues = mobileValues;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new …
Run Code Online (Sandbox Code Playgroud) 我想从列表视图项的片段开始服务.我试图用以下方式呼叫服务:
startService(new Intent(getActivity(),myPlayService.class));
Run Code Online (Sandbox Code Playgroud)
但它根本不起作用.我如何从片段中调用我的服务?还有其他方法可以开始服务吗?
我想在Android应用程序中为其简介(登录/注册)屏幕实现相同类型的动画,例如链接.
我正在使用视图寻呼机进行简介屏幕,我想在背景图像更改时实现fadein fadeout动画,按照从右向左滑动或反之亦然.我想根据屏幕的滑动在背景图像变化上实现fadein和fadeout动画.任何帮助表示赞赏.请看一下我的布局代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/background_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="7" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="right"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:src="@drawable/icon_skip" />
<TextView
android:id="@+id/skip_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Skip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="bottom"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/logo" />
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.xyz.View.IntroductionScreen" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/connection_bt"
android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud) 我是NDK的新手,所以我阅读了教程,我成功构建了FFMPEG lib,而不是将其复制到我的jni文件夹中创建Android.mk和Application.mk文件并执行ndk-build命令,所以现在我将libavcodec.so放入我的lib文件夹..(我没有将ffmpeg头文件复制到我的jni文件夹..是否有必要添加头文件或者我应该将完整的ffmpeg lib添加到jni ... stack-overflow评论说你只需要添加头文件)
我知道,如果我想将我的相机视频转换为小尺寸,而不是通过使用avcodac.so来压缩它,所以我编译它但重要的是这是我如何使用它.
在我的脑海中使用那个文件有困惑.. 1)我是否需要使用System.load("libavcodec.so")方法来加载So文件如果加载后文件是,我怎样才能访问C的本机方法/ C++?
2)或者我是否需要创建我的java类和我的c类,它们彼此通信并且c类与avcodec类的ffmpeg进行通信?
或者应该需要实现两个和一个更重要的事情,如果我必须创建我的c类比在Android.mk我必须将其添加到源文件行???
请问任何人都可以告诉我在FFMPEG中压缩视频文件大小的方法和步骤是什么?
任何帮助表示赞赏,我的问题也将有助于其他新鲜事.谢谢
我希望通知会在音乐停止播放之前粘在通知栏上.目前我已经写了一些代码,我可以在其中显示通知,但是当我按下清除通知按钮或交换它时,它会从通知中心消失.我想要像spotify一样的通知,直到你停止播放音乐为止.这是我的通知代码
int pendingRequestCode = 0;
// final Resources res = getResources();
notificationManager = (NotificationManager) getSystemService(
NOTIFICATION_SERVICE);
Intent i = new Intent(getApplicationContext(),Mainactivity.class);
Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_action_search)
.setAutoCancel(true)
.setTicker("test ckick")
.setContentIntent(PendingIntent.getActivity(getApplicationContext(), NOTIFICATION_DEFAULT, i,0));
// Sets a custom content view for the notification, including an image button.
layout = new RemoteViews(getPackageName(), R.layout.notification);
layout.setTextViewText(R.id.notification_title, getString(R.string.app_name));
Intent clickIntent = new Intent();
clickIntent.setAction(ACTION_DIALOG);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), pendingRequestCode, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
layout.setOnClickPendingIntent(R.id.notification_button,pendingIntent);
builder.setContent(layout);
// Notifications in Android 3.0 now have a standard mechanism for displaying …
Run Code Online (Sandbox Code Playgroud) 我想将此工具添加到我的应用程序中,用户可以在其中设置应用程序启动时间,然后应用程序启动.如何在用户特定时间使用广播接收器打开我的应用程序.我不确定这在Android中是否可行?如果你有什么想法请分享.这是主要的活动代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv1=(ListView)findViewById(R.id.listView);
final ImageView splashImage = (ImageView) findViewById(R.id.imageView1);
splashImage.setBackgroundResource(R.layout.splash);
AnimationDrawable splashAnimation = (AnimationDrawable) splashImage.getBackground();
splashImage.onWindowFocusChanged(true);
splashAnimation.start();
AlarmManager am = (AlarmManager) getBaseContext().getSystemService(Context.ALARM_SERVICE);
Date futureDate = new Date(new Date().getTime() + 86400000);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, 1);// start app in 1 min again
futureDate.setHours(0);
futureDate.setMinutes(0);
futureDate.setSeconds(20);
Intent intent = new Intent(getBaseContext(), MyAppReciever.class);
PendingIntent sender = PendingIntent.getBroadcast(getBaseContext(), 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
am.set(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis() , sender);}}
Run Code Online (Sandbox Code Playgroud)
这是reciver类代码
class MyAppReciever extends BroadcastReceiver{ public void onReceive(Context context,Intent intent) {
startActivity(new Intent(context, …
Run Code Online (Sandbox Code Playgroud) 我想在UILabel中显示前500个字符,如果有超过500个字符,则显示截断图标.但我不知道如何限制500个字符来截断文本?
这是我的代码
label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 350, self.bounds.size.width, 30)];
// In this case value of self.bounds.size.width is "427"
label2.backgroundColor = [UIColor clearColor];
label2.numberOfLines = 2;
label2.textAlignment = UITextAlignmentCenter;
label2.font = [UIFont systemFontOfSize:13];
[self addSubview:label2]
//Here is Implimentation code of my label
NSString *temp = [galleryEntryTree objectForKey:@"description"];// calling lebel text from database
coverView.label2.text = temp;
coverView.label2.adjustsFontSizeToFitWidth = NO;
coverView.label2.lineBreakMode = UILineBreakModeTailTruncation;
Run Code Online (Sandbox Code Playgroud)
告诉我们伙计们如何显示最少500个字符而不是截断它(如果超过500个)
任何帮助表示赞赏
我对"钥匙扣访问的潜在损失"几乎没有疑问.
我将一个应用程序从旧帐户转移到新帐户但现在我想要更新该应用程序,当我尝试提交更新构建xcode时显示我警告可能丢失钥匙串访问但没有错误(使用xcode的新配置文件).所以我在google上搜索它,我发现它因为旧的团队ID和新的团队ID,它的不同而且因为你不能拥有包含旧团队ID的配置文件.所以我使用XCode创建新的配置文件,例如"xc:com.TESTING.Test",并使用warrining提交app.
但在提交应用程序后,我收到一封来自苹果的电子邮件,说"先前版本的软件的应用程序标识符值为['XYZXYZ.com.TESTING.Test'],并且提交的新版软件的应用程序标识符为[ 'ABCABC.com.TESTING.Test'].这将导致钥匙串访问丢失."
所以我的问题如下: -
1)如果我使用新的配置文件忽略"keychain access warrning",那么我的应用程序将无法访问NSUSerDefaults?或任何其他重要信息?(只有旧安装或新安装才会出现此问题,也无法访问钥匙串?)
2)如何解决这个问题?
任何帮助都是适当的
谢谢
我想在列表视图的每一行中显示N个imageview.imageview的数量取决于json解析值.每次从服务器获取json时,它可以是2或3或4.
所以我不能通过使用inflate使用静态xml.所以我决定在getview方法中创建动态视图并在视图中添加N个imageview
我写下面的代码,但它仍然只显示一个imageview和水平滚动根本不工作..
任何帮助表示赞赏
public class MyAdapter extends BaseAdapter{
private LayoutInflater inflater;
private ArrayList<String> data;
Context con;
public MyAdapter(Context context, ArrayList<String> data1){
// Caches the LayoutInflater for quicker use
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Sets the events data
data= data1;
con=context;
}
public View getView(int position, View view, ViewGroup viewgroup) {
ViewHolder holder=new ViewHolder(); //our view holder of the row
if (view == null) {
HorizontalScrollView hr=new HorizontalScrollView(con);
LinearLayout layout=new LinearLayout(con);
layout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
//layout set some properties
for(int i=1;i<2;i++)
{
holder.image …
Run Code Online (Sandbox Code Playgroud) 我想将字符串从片段传递到服务.我试过setvalue和bind,但它适用于活动而不是startservice对吗?什么是"ServiceConnection",通过使用ServiceConnection可以传递字符串?这是我的片段代码来启动服务.
**Solved **
Run Code Online (Sandbox Code Playgroud)
我已将我的代码更改为此,并且它完美无缺
Intent intent = new Intent(getActivity(), myPlayService.class);
Bundle b = new Bundle();
b.putString("link", "http://94.23.154/bbc");
intent.putExtras(b);
getActivity().startService(intent);
Run Code Online (Sandbox Code Playgroud)
我在使用中
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
if(intent != null){
Bundle bundle = intent.getExtras();
link = bundle.getString("link");
}
Run Code Online (Sandbox Code Playgroud) 我尝试了一切来改变actionsherlock栏上的图标,但它只是显示我的android徽标.我试过这个替换图标但失败了.我正在使用自定义主题的动作栏颜色.
getSupportActionBar().setIcon(R.drawable.ic_launcher);
Run Code Online (Sandbox Code Playgroud)
这是我的string.xml
<style name="Theme.MyTheme" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item></style><style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar"><item name="android:background">@drawable/actionbar</item><item name="background">@drawable/actionbar</item><item name="android:displayOptions">showHome</item></style>
Run Code Online (Sandbox Code Playgroud)
这是清单文件
<application android:label="Myapp"
android:logo="@drawable/ic_launcher">
<activity
android:name="com.android.twitter.SplashScreen"
android:launchMode="singleTop"
android:configChanges="orientation|screenSize"
android:theme="@style/Theme.MyTheme"
/>
Run Code Online (Sandbox Code Playgroud)
我不想在动作栏上显示标题..我只是想显示我的应用程序的徽标所以有没有办法通过编码更改图标?谢谢
android ×10
ios ×2
iphone ×2
android-ndk ×1
animation ×1
certificate ×1
ffmpeg ×1
imageview ×1
ios5 ×1
uilabel ×1