小编ast*_*ter的帖子

从Android TV中的BrowseFragment中删除上边距

如何删除空白区域,如下图中虚线框所示 BrowseFragment.我设法删除搜索按钮和标题.虽然,我还想删除空白区域并在屏幕顶​​部移动视频行.

有没有办法做到这一点?

我尝试在我的AppTheme中设置以下内容,但我怀疑它有帮助:

    <item name="browseRowsMarginTop">0dp</item>
    <item name="browsePaddingTop">0dp</item>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

android android-tv browsefragment

5
推荐指数
1
解决办法
1667
查看次数

如何获得EditText的焦点并使用Android TV中的D-pad进行导航

我正在使用EditText&PopupWindow由于一些GUI要求创建基于建议的搜索功能.搜索和建议工作正常,但我无法浏览搜索EditText和列出PopupWindow通过Dpad的项目.

以下是我整个屏幕的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
    android:id="@+id/center_baseline"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_centerInParent="true" />

<View
    android:id="@+id/top_baseline"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_above="@+id/center_baseline"
    android:layout_marginBottom="50dp" />

<View
    android:id="@+id/bottom_baseline"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/center_baseline"
    android:layout_marginTop="45dp" />

<RelativeLayout
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignBottom="@id/bottom_baseline"
    android:layout_alignParentTop="true"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true">

    <ImageView
        android:id="@+id/top_shelf_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="@dimen/top_shelf_image_alpha"
        android:contentDescription="@string/app_name"
        android:scaleType="fitXY" />

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/home_screen_top_bar_height"
        android:layout_alignParentTop="true"
        android:alpha="@dimen/home_screen_top_bar_alpha"
        android:background="@color/black" />

    <ImageView
        android:id="@+id/app_logo"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/home_screen_logo_height"
        android:layout_marginLeft="20dp"
        android:contentDescription="@string/app_name"
        android:gravity="center"
        android:padding="5dp"
        android:src="@drawable/ic_app_logo" />

    <EditText
        android:id="@+id/team_search_bar"
        android:layout_width="@dimen/home_screen_search_bar_width"
        android:layout_height="@dimen/home_screen_logo_height"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:hint="@string/lb_search_bar_hint"
        android:imeOptions="actionSearch" …
Run Code Online (Sandbox Code Playgroud)

search android android-edittext d-pad android-tv

5
推荐指数
0
解决办法
789
查看次数

Java string.equals函数是否存在不等式?

此代码将用户输入的文本(userText)与关键字(endProgram)进行比较.当用户输入单词exit时,程序将完成并关闭.

public static void main(String[] args) {

    String endProgram = "exit";
    String userInput;

    java.util.Scanner input = new java.util.Scanner(System.in);

    do {
        userInput = input.nextLine();
    } while ( !(userInput.equals(endProgram)) );

}
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法在while括号内编写代码?也就是说,而不是使用 !(String.equals(String))是否有另一个功能来比较不平等?

java string inequality string-comparison

3
推荐指数
1
解决办法
5384
查看次数

如何将listview转换为gridview

下面是我的代码,可以很好地水平显示列表视图。如何将其更改为gridvew。我应该进行哪些更改才能将其更改为gridview?请帮帮我

public class fifthscreen extends Activity {

int IOConnect = 0;

String _response;
String status;

HorizontalListView listview;
CategoryListAdapter3 cla;

String URL, URL2;
String SelectMenuAPI;
static ArrayList<Long> Category_ID = new ArrayList<Long>();
static ArrayList<String> Category_name = new ArrayList<String>();
static ArrayList<String> Category_image = new ArrayList<String>();
public static String allergen2;

String name;

String url1;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fifthscreen);

    listview = (HorizontalListView) this.findViewById(R.id.listview2);

    cla = new CategoryListAdapter3(fifthscreen.this);
    new TheTask().execute();
}

public class TheTask extends AsyncTask<Void, String, String> {

    @Override
    protected void …
Run Code Online (Sandbox Code Playgroud)

android android-listview

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

如何在Android设备上使用pjsip以获得G.729编解码器功能

我想G.729在我的Android应用程序上使用音频编解码器.我对此做了很多研究,并且开始知道这pjsip是最有希望的解决方案.但我对这一切并不太了解.有人可以为我提供pjsip在现有Android应用程序中使用的完整步骤,以及如何通过包含对G729编解码器的支持pjsip.

任何帮助将不胜感激.

编辑:

这是我的android.mk档案.我想知道,我做对了吗?以及如何C在我的java代码中使用这些函数???

include $(CLEAR_VARS)
LOCAL_MODULE := pjsua-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := $(MY_PJLIB_PATH)/libpjsua-arm-unknown-linux-androideabi.a

 PJSIP_LIBS := $(addprefix pjsip_libs/, \
 libg7221codec-arm-unknown-linux-androideabi.a \
 libg7221codec-i686-apple-darwin9.a \
 libgsmcodec-arm-unknown-linux-androideabi.a \
 libgsmcodec-i686-apple-darwin9.a \
 libilbccodec-arm-unknown-linux-androideabi.a \
 libmilenage-arm-unknown-linux-androideabi.a \
 libmilenage-i686-apple-darwin9.a \
 libpj-arm-unknown-linux-androideabi.a \
 libpj-i686-apple-darwin9.a \
 libpjlib-util-arm-unknown-linux-androideabi.a \
 libpjlib-util-i686-apple-darwin9.a \
 libpjmedia-audiodev-i686-apple-darwin9.a \
 libpjmedia-codec-i686-apple-darwin9.a \
 libpjmedia-i686-apple-darwin9.a \
 libpjmedia-videodev-i686-apple-darwin9.a \
 libpjnath-arm-unknown-linux-androideabi.a \
 libpjnath-i686-apple-darwin9.a \
 libpjsdp-i686-apple-darwin9.a \
 libpjsip-i686-apple-darwin9.a \
 libpjsip-simple-i686-apple-darwin9.a \
 libpjsip-ua-i686-apple-darwin9.a \
 libpjsua-i686-apple-darwin9.a \
 libportaudio-i686-apple-darwin9.a \
 libresample-arm-unknown-linux-androideabi.a \
 libresample-i686-apple-darwin9.a …
Run Code Online (Sandbox Code Playgroud)

android voip sip codec pjsip

3
推荐指数
1
解决办法
6205
查看次数

Android 5中的意图动作调用

我有这个代码,在Android 4.4和之前的版本中工作正常:

Intent intent = new Intent(Intent.ACTION_CALL);         
intent.setPackage("com.android.phone");
intent.setData(Uri.parse("tel:" + number));
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

现在,在Android 5.0 Lollipop中,此代码不起作用,并显示此异常:

Fatal Exception: android.content.ActivityNotFoundException
No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxx pkg=com.android.phone }
Run Code Online (Sandbox Code Playgroud)

在文档中,这Intent似乎不被弃用:

任何的想法?提前致谢

android android-intent android-5.0-lollipop

3
推荐指数
1
解决办法
5738
查看次数

错误:不使用支持库时应使用android:showAsAction

我正在使用app紧凑支持库v7在我的应用程序中提供棒棒糖的支持.我能够让它完美地运作.当我的操作栏没有将菜单项显示为图标时.

我已按照 此链接使其工作.
以下是我的menu.xml:

<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android" >


<item
    android:id="@+id/contact_add"
    android:icon="@drawable/ic_btn_add_contact"
    android:title="@string/add" 
    app:showAsAction="always"/>
<item
    android:id="@+id/contact_delete"
    android:icon="@drawable/ic_btn_add_contact"
    android:showAsAction="never"
    android:title="@string/delete"/>
</menu>
Run Code Online (Sandbox Code Playgroud)

我仍然收到以下错误: should use android:showAsAction when not using appcompat library

我究竟做错了什么 ???

android menuitem android-fragments android-actionbar android-support-library

2
推荐指数
1
解决办法
6388
查看次数

尝试在空对象参考上调用虚方法'com.orm.Database com.orm.SugarApp.getDatabase()'

我正在使用Android Studio开发我的Android应用程序.在我的应用程序中,我需要一些db sqlite操作.我开始使用Sugar ORM.根据最新版本的糖1.3.jar不需要任何上下文初始化.

所以我开始这样编码

Iterator<Order> orders = Order.findAll(Order.class);

<meta-data android:name="DATABASE" android:value="dbname.db" />
    <meta-data android:name="VERSION" android:value="2" />
    <meta-data android:name="QUERY_LOG" android:value="true" />
    <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="value" />
Run Code Online (Sandbox Code Playgroud)

在menifast文件中.

但我遇到的问题是

java.lang.RuntimeException:无法启动活动ComponentInfo {package.HomeActivity}:java.lang.NullPointerException:尝试在空对象参考上调用虚方法'com.orm.Database com.orm.SugarApp.getDatabase()'

你觉得我需要做别的事还是错过了什么?请帮忙.

谢谢

android

2
推荐指数
1
解决办法
2434
查看次数

UILabel没有响应触摸事件

我正在使用以下代码来创建我的视图.我UILabel在滚动视图中.现在我想在touchesBegan我的自定义标签的方法中点击事件.但无法得到它.

        img1 = [[customLabel alloc] initWithFrame:CGRectMake(0,height ,280,10 )];//
        [img1 setText: [self.answer_set objectAtIndex:i]];
        [img1 setTextAlignment:NSTextAlignmentLeft];
        [img1 setBackgroundColor:[UIColor colorWithRed:127.0f/255.0f green:165.0f/255.0f blue:234.0f/255.0f alpha:1.0f]];
        img1.textColor = [UIColor whiteColor];
        img1.lineBreakMode = NSLineBreakByWordWrapping;
        img1.numberOfLines = 0;
        [img1 sizeToFit];
        img1.contentMode = UIViewContentModeScaleToFill;
        img1.font = [UIFont fontWithName:@"Arial" size:14.0f] ;

        CGFloat labelHeight=[self getStringHeightforLabel:img1];
        NSLog(@"LABEL HEIGHT:: %f",labelHeight);
        //set frame after getting height
        if (labelHeight < 60.0) {
            labelHeight = 60.0;
        }

        [img1 setUserInteractionEnabled:YES];
        img1.tag = 5000;

        img1.frame=CGRectMake(-5,height,285 + 10,labelHeight + 10);
        img1.layer.cornerRadius = 5;


        /** Shadow …
Run Code Online (Sandbox Code Playgroud)

objective-c uilabel ios

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

indexpath.row显示的行数较少

tableview用数组创建了一个.我的阵列中有7个项目.但是cellForRowAtIndexPath方法我无法得到indexpath.row == 6.可能是什么原因.代码如下.

  -(void)viewDidLoad
    {
      [super viewDidLoad];

      self.menu = [NSArray arrayWithObjects:@"Home",@"ansCategory",@"askQue",@"myQue",@"likedQue", @"topQue", @"topUser",nil];             
    }

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
     {
       // Return the number of sections.
       return 1;
     }

      -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
     {
        // Return the number of rows in the section.
        // NSLog(@"count::::::%d",self.menu.count);
           return self.menu.count;
     }
       -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString *cellIdentifier = @"Cell";    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle                   reuseIdentifier:cellIdentifier];

        NSLog(@"rows:%@",indexPath);
        NSLog(@"row:%@",[self.menu objectAtIndex:indexPath.row]);
    } …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview ios

0
推荐指数
1
解决办法
2807
查看次数